|
@@ -73,49 +73,49 @@ describe( 'position', function() {
|
|
|
it( 'should create a position with path and document', function() {
|
|
it( 'should create a position with path and document', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- var position = new Position( [ 0 ], doc );
|
|
|
|
|
|
|
+ var position = new Position( [ 0 ], doc.root );
|
|
|
|
|
|
|
|
expect( position ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
|
|
expect( position ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
|
|
|
- expect( position ).to.have.property( 'doc' ).that.equals( doc );
|
|
|
|
|
|
|
+ expect( position ).to.have.property( 'root' ).that.equals( doc.root );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should make positions form node and offset', function() {
|
|
it( 'should make positions form node and offset', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( root, 0, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( root, 1, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( root, 2, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( root, 0, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( root, 1, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( root, 2, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( p, 0, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 0, 0 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( p, 0, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 0, 0 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( ul, 0, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( ul, 1, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( ul, 2, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( ul, 0, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( ul, 1, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( ul, 2, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( li1, 0, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( li1, 1, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( li1, 2, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
|
|
|
|
|
- expect( Position.makePositionFromParentAndOffset( li1, 3, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( li1, 0, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( li1, 1, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( li1, 2, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
|
|
|
|
|
+ expect( Position.makePositionFromParentAndOffset( li1, 3, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should make positions before elements', function() {
|
|
it( 'should make positions before elements', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( Position.makePositionBefore( p, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionBefore( p, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionBefore( ul, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionBefore( ul, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionBefore( li1, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionBefore( li1, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionBefore( f, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
|
|
|
|
|
- expect( Position.makePositionBefore( o, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
|
|
|
|
|
- expect( Position.makePositionBefore( z, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionBefore( f, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
|
|
|
|
|
+ expect( Position.makePositionBefore( o, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
|
|
|
|
|
+ expect( Position.makePositionBefore( z, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionBefore( li2, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionBefore( li2, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionBefore( b, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 0 ] );
|
|
|
|
|
- expect( Position.makePositionBefore( a, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
|
|
|
|
|
- expect( Position.makePositionBefore( r, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionBefore( b, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 0 ] );
|
|
|
|
|
+ expect( Position.makePositionBefore( a, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
|
|
|
|
|
+ expect( Position.makePositionBefore( r, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should throw error if one try to make positions before root', function() {
|
|
it( 'should throw error if one try to make positions before root', function() {
|
|
@@ -123,28 +123,28 @@ describe( 'position', function() {
|
|
|
var CKEditorError = modules.ckeditorerror;
|
|
var CKEditorError = modules.ckeditorerror;
|
|
|
|
|
|
|
|
expect( function() {
|
|
expect( function() {
|
|
|
- Position.makePositionBefore( root, doc );
|
|
|
|
|
|
|
+ Position.makePositionBefore( root, doc.root );
|
|
|
} ).to.throw( CKEditorError, /position-before-root/ );
|
|
} ).to.throw( CKEditorError, /position-before-root/ );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should make positions after elements', function() {
|
|
it( 'should make positions after elements', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( Position.makePositionAfter( p, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionAfter( p, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionAfter( ul, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionAfter( ul, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionAfter( li1, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionAfter( li1, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionAfter( f, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
|
|
|
|
|
- expect( Position.makePositionAfter( o, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
|
|
|
|
|
- expect( Position.makePositionAfter( z, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionAfter( f, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
|
|
|
|
|
+ expect( Position.makePositionAfter( o, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
|
|
|
|
|
+ expect( Position.makePositionAfter( z, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionAfter( li2, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionAfter( li2, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
|
|
|
|
|
|
|
|
- expect( Position.makePositionAfter( b, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
|
|
|
|
|
- expect( Position.makePositionAfter( a, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
|
|
|
|
|
- expect( Position.makePositionAfter( r, doc ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 3 ] );
|
|
|
|
|
|
|
+ expect( Position.makePositionAfter( b, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
|
|
|
|
|
+ expect( Position.makePositionAfter( a, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
|
|
|
|
|
+ expect( Position.makePositionAfter( r, doc.root ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 3 ] );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should throw error if one try to make positions after root', function() {
|
|
it( 'should throw error if one try to make positions after root', function() {
|
|
@@ -152,91 +152,91 @@ describe( 'position', function() {
|
|
|
var CKEditorError = modules.ckeditorerror;
|
|
var CKEditorError = modules.ckeditorerror;
|
|
|
|
|
|
|
|
expect( function() {
|
|
expect( function() {
|
|
|
- Position.makePositionAfter( root, doc );
|
|
|
|
|
|
|
+ Position.makePositionAfter( root, doc.root );
|
|
|
} ).to.throw( CKEditorError, /position-after-root/ );
|
|
} ).to.throw( CKEditorError, /position-after-root/ );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should have parent', function() {
|
|
it( 'should have parent', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( new Position( [ 0 ], doc ) ).to.have.property( 'parent' ).that.equals( root );
|
|
|
|
|
- expect( new Position( [ 1 ], doc ) ).to.have.property( 'parent' ).that.equals( root );
|
|
|
|
|
- expect( new Position( [ 2 ], doc ) ).to.have.property( 'parent' ).that.equals( root );
|
|
|
|
|
|
|
+ expect( new Position( [ 0 ], doc.root ) ).to.have.property( 'parent' ).that.equals( root );
|
|
|
|
|
+ expect( new Position( [ 1 ], doc.root ) ).to.have.property( 'parent' ).that.equals( root );
|
|
|
|
|
+ expect( new Position( [ 2 ], doc.root ) ).to.have.property( 'parent' ).that.equals( root );
|
|
|
|
|
|
|
|
- expect( new Position( [ 0, 0 ], doc ) ).to.have.property( 'parent' ).that.equals( p );
|
|
|
|
|
|
|
+ expect( new Position( [ 0, 0 ], doc.root ) ).to.have.property( 'parent' ).that.equals( p );
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0 ], doc ) ).to.have.property( 'parent' ).that.equals( ul );
|
|
|
|
|
- expect( new Position( [ 1, 1 ], doc ) ).to.have.property( 'parent' ).that.equals( ul );
|
|
|
|
|
- expect( new Position( [ 1, 2 ], doc ) ).to.have.property( 'parent' ).that.equals( ul );
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0 ], doc.root ) ).to.have.property( 'parent' ).that.equals( ul );
|
|
|
|
|
+ expect( new Position( [ 1, 1 ], doc.root ) ).to.have.property( 'parent' ).that.equals( ul );
|
|
|
|
|
+ expect( new Position( [ 1, 2 ], doc.root ) ).to.have.property( 'parent' ).that.equals( ul );
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0, 0 ], doc ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
- expect( new Position( [ 1, 0, 1 ], doc ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
- expect( new Position( [ 1, 0, 2 ], doc ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
- expect( new Position( [ 1, 0, 3 ], doc ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0, 0 ], doc.root ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 1 ], doc.root ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 2 ], doc.root ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 3 ], doc.root ) ).to.have.property( 'parent' ).that.equals( li1 );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should have offset', function() {
|
|
it( 'should have offset', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( new Position( [ 0 ], doc ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
- expect( new Position( [ 1 ], doc ) ).to.have.property( 'offset' ).that.equals( 1 );
|
|
|
|
|
- expect( new Position( [ 2 ], doc ) ).to.have.property( 'offset' ).that.equals( 2 );
|
|
|
|
|
|
|
+ expect( new Position( [ 0 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
+ expect( new Position( [ 1 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 1 );
|
|
|
|
|
+ expect( new Position( [ 2 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 2 );
|
|
|
|
|
|
|
|
- expect( new Position( [ 0, 0 ], doc ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
|
|
+ expect( new Position( [ 0, 0 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0 ], doc ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
- expect( new Position( [ 1, 1 ], doc ) ).to.have.property( 'offset' ).that.equals( 1 );
|
|
|
|
|
- expect( new Position( [ 1, 2 ], doc ) ).to.have.property( 'offset' ).that.equals( 2 );
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
+ expect( new Position( [ 1, 1 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 1 );
|
|
|
|
|
+ expect( new Position( [ 1, 2 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 2 );
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0, 0 ], doc ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
- expect( new Position( [ 1, 0, 1 ], doc ) ).to.have.property( 'offset' ).that.equals( 1 );
|
|
|
|
|
- expect( new Position( [ 1, 0, 2 ], doc ) ).to.have.property( 'offset' ).that.equals( 2 );
|
|
|
|
|
- expect( new Position( [ 1, 0, 3 ], doc ) ).to.have.property( 'offset' ).that.equals( 3 );
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0, 0 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 0 );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 1 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 1 );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 2 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 2 );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 3 ], doc.root ) ).to.have.property( 'offset' ).that.equals( 3 );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should have nodeBefore', function() {
|
|
it( 'should have nodeBefore', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( new Position( [ 0 ], doc ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
- expect( new Position( [ 1 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( p );
|
|
|
|
|
- expect( new Position( [ 2 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( ul );
|
|
|
|
|
|
|
+ expect( new Position( [ 0 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
+ expect( new Position( [ 1 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( p );
|
|
|
|
|
+ expect( new Position( [ 2 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( ul );
|
|
|
|
|
|
|
|
- expect( new Position( [ 0, 0 ], doc ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
|
|
+ expect( new Position( [ 0, 0 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0 ], doc ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
- expect( new Position( [ 1, 1 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( li1 );
|
|
|
|
|
- expect( new Position( [ 1, 2 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( li2 );
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
+ expect( new Position( [ 1, 1 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( li1 );
|
|
|
|
|
+ expect( new Position( [ 1, 2 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( li2 );
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0, 0 ], doc ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
- expect( new Position( [ 1, 0, 1 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( f );
|
|
|
|
|
- expect( new Position( [ 1, 0, 2 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( o );
|
|
|
|
|
- expect( new Position( [ 1, 0, 3 ], doc ) ).to.have.property( 'nodeBefore' ).that.equals( z );
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0, 0 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.is.null;
|
|
|
|
|
+ expect( new Position( [ 1, 0, 1 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( f );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 2 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( o );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 3 ], doc.root ) ).to.have.property( 'nodeBefore' ).that.equals( z );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should have nodeAfter', function() {
|
|
it( 'should have nodeAfter', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- expect( new Position( [ 0 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( p );
|
|
|
|
|
- expect( new Position( [ 1 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( ul );
|
|
|
|
|
- expect( new Position( [ 2 ], doc ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
+ expect( new Position( [ 0 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( p );
|
|
|
|
|
+ expect( new Position( [ 1 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( ul );
|
|
|
|
|
+ expect( new Position( [ 2 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
|
- expect( new Position( [ 0, 0 ], doc ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
+ expect( new Position( [ 0, 0 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( li1 );
|
|
|
|
|
- expect( new Position( [ 1, 1 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( li2 );
|
|
|
|
|
- expect( new Position( [ 1, 2 ], doc ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( li1 );
|
|
|
|
|
+ expect( new Position( [ 1, 1 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( li2 );
|
|
|
|
|
+ expect( new Position( [ 1, 2 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
|
- expect( new Position( [ 1, 0, 0 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( f );
|
|
|
|
|
- expect( new Position( [ 1, 0, 1 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( o );
|
|
|
|
|
- expect( new Position( [ 1, 0, 2 ], doc ) ).to.have.property( 'nodeAfter' ).that.equals( z );
|
|
|
|
|
- expect( new Position( [ 1, 0, 3 ], doc ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
|
|
|
|
+ expect( new Position( [ 1, 0, 0 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( f );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 1 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( o );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 2 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.equals( z );
|
|
|
|
|
+ expect( new Position( [ 1, 0, 3 ], doc.root ) ).to.have.property( 'nodeAfter' ).that.is.null;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should equals another position with the same path', function() {
|
|
it( 'should equals another position with the same path', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- var position = new Position( [ 1, 1, 2 ], doc );
|
|
|
|
|
- var samePosition = new Position( [ 1, 1, 2 ], doc );
|
|
|
|
|
|
|
+ var position = new Position( [ 1, 1, 2 ], doc.root );
|
|
|
|
|
+ var samePosition = new Position( [ 1, 1, 2 ], doc.root );
|
|
|
|
|
|
|
|
expect( position.isEqual( samePosition ) ).to.be.true;
|
|
expect( position.isEqual( samePosition ) ).to.be.true;
|
|
|
} );
|
|
} );
|
|
@@ -244,8 +244,8 @@ describe( 'position', function() {
|
|
|
it( 'should not equals another position with the different path', function() {
|
|
it( 'should not equals another position with the different path', function() {
|
|
|
var Position = modules[ 'document/position' ];
|
|
var Position = modules[ 'document/position' ];
|
|
|
|
|
|
|
|
- var position = new Position( [ 1, 1, 1 ], doc );
|
|
|
|
|
- var differentNode = new Position( [ 1, 2, 2 ], doc );
|
|
|
|
|
|
|
+ var position = new Position( [ 1, 1, 1 ], doc.root );
|
|
|
|
|
+ var differentNode = new Position( [ 1, 2, 2 ], doc.root );
|
|
|
|
|
|
|
|
expect( position.isEqual( differentNode ) ).to.be.false;
|
|
expect( position.isEqual( differentNode ) ).to.be.false;
|
|
|
} );
|
|
} );
|