Ver código fonte

Tests: move treeModel.Schema tests to proper directory.

Szymon Cofalik 9 anos atrás
pai
commit
b2363ca634

+ 26 - 26
packages/ckeditor5-engine/tests/schema/schema.js → packages/ckeditor5-engine/tests/treemodel/schema/schema.js

@@ -24,19 +24,19 @@ describe( 'constructor', () => {
 
 		schema = new Schema();
 
-		expect( schema.registerItem.calledWithExactly( 'inline', null ) );
-		expect( schema.registerItem.calledWithExactly( 'block', null ) );
-		expect( schema.registerItem.calledWithExactly( 'root', null ) );
+		expect( schema.registerItem.calledWithExactly( '$inline', null ) );
+		expect( schema.registerItem.calledWithExactly( '$block', null ) );
+		expect( schema.registerItem.calledWithExactly( '$root', null ) );
 
 		Schema.prototype.registerItem.restore();
 	} );
 
 	it( 'should allow inline in block', () => {
-		expect( schema.checkForPath( { name: 'inline' }, [ 'block' ] ) ).to.be.true;
+		expect( schema.checkForPath( { name: '$inline' }, [ '$block' ] ) ).to.be.true;
 	} );
 
 	it( 'should allow block in root', () => {
-		expect( schema.checkForPath( { name: 'block' }, [ 'root' ] ) ).to.be.true;
+		expect( schema.checkForPath( { name: '$block' }, [ '$root' ] ) ).to.be.true;
 	} );
 } );
 
@@ -60,9 +60,9 @@ describe( 'registerItem', () => {
 	} );
 
 	it( 'should make registered item inherit allows from base item', () => {
-		schema.registerItem( 'div', 'block' );
+		schema.registerItem( 'div', '$block' );
 
-		expect( schema.checkForPath( { name: 'div' }, [ 'root' ] ) ).to.be.true;
+		expect( schema.checkForPath( { name: 'div' }, [ '$root' ] ) ).to.be.true;
 	} );
 
 	it( 'should throw if item with given name has already been registered in schema', () => {
@@ -82,7 +82,7 @@ describe( 'registerItem', () => {
 
 describe( 'hasItem', () => {
 	it( 'should return true if given item name has been registered in schema', () => {
-		expect( schema.hasItem( 'block' ) ).to.be.true;
+		expect( schema.hasItem( '$block' ) ).to.be.true;
 	} );
 
 	it( 'should return false if given item name has not been registered in schema', () => {
@@ -108,8 +108,8 @@ describe( '_getItem', () => {
 
 describe( 'allow', () => {
 	it( 'should add passed query to allowed in schema', () => {
-		schema.registerItem( 'p', 'block' );
-		schema.registerItem( 'div', 'block' );
+		schema.registerItem( 'p', '$block' );
+		schema.registerItem( 'div', '$block' );
 
 		expect( schema.checkForPath( { name: 'p' }, [ 'div' ] ) ).to.be.false;
 
@@ -121,10 +121,10 @@ describe( 'allow', () => {
 
 describe( 'disallow', () => {
 	it( 'should add passed query to disallowed in schema', () => {
-		schema.registerItem( 'p', 'block' );
-		schema.registerItem( 'div', 'block' );
+		schema.registerItem( 'p', '$block' );
+		schema.registerItem( 'div', '$block' );
 
-		schema.allow( { name: 'block', attribute: 'bold', inside: 'div' } );
+		schema.allow( { name: '$block', attribute: 'bold', inside: 'div' } );
 
 		expect( schema.checkForPath( { name: 'p', attribute: 'bold' }, [ 'div' ] ) ).to.be.true;
 
@@ -147,20 +147,20 @@ describe( 'checkAtPosition', () => {
 			new Element( 'p' )
 		] );
 
-		schema.registerItem( 'div', 'block' );
-		schema.registerItem( 'header', 'block' );
-		schema.registerItem( 'p', 'block' );
+		schema.registerItem( 'div', '$block' );
+		schema.registerItem( 'header', '$block' );
+		schema.registerItem( 'p', '$block' );
 
 		schema.allow( { name: 'p', inside: 'div' } );
 		schema.allow( { name: 'header', inside: 'div' } );
-		schema.allow( { name: 'inline', attribute: 'bold', inside: 'block' } );
+		schema.allow( { name: '$inline', attribute: 'bold', inside: '$block' } );
 
-		schema.disallow( { name: 'inline', attribute: 'bold', inside: 'header' } );
+		schema.disallow( { name: '$inline', attribute: 'bold', inside: 'header' } );
 	} );
 
 	it( 'should return true if given element is allowed by schema at given position', () => {
 		// Block should be allowed in root.
-		expect( schema.checkAtPosition( { name: 'block' }, new Position( root, [ 0 ] ) ) ).to.be.true;
+		expect( schema.checkAtPosition( { name: '$block' }, new Position( root, [ 0 ] ) ) ).to.be.true;
 
 		// P is block and block should be allowed in root.
 		expect( schema.checkAtPosition( { name: 'p' }, new Position( root, [ 0 ] ) ) ).to.be.true;
@@ -170,10 +170,10 @@ describe( 'checkAtPosition', () => {
 
 		// Inline is allowed in any block and is allowed with attribute bold.
 		// We do not check if it is allowed in header, because it is disallowed by the set rule.
-		expect( schema.checkAtPosition( { name: 'inline' }, new Position( root, [ 0, 0 ] ) ) ).to.be.true;
-		expect( schema.checkAtPosition( { name: 'inline' }, new Position( root, [ 2, 0 ] ) ) ).to.be.true;
-		expect( schema.checkAtPosition( { name: 'inline', attribute: 'bold' }, new Position( root, [ 0, 0 ] ) ) ).to.be.true;
-		expect( schema.checkAtPosition( { name: 'inline', attribute: 'bold' }, new Position( root, [ 2, 0 ] ) ) ).to.be.true;
+		expect( schema.checkAtPosition( { name: '$inline' }, new Position( root, [ 0, 0 ] ) ) ).to.be.true;
+		expect( schema.checkAtPosition( { name: '$inline' }, new Position( root, [ 2, 0 ] ) ) ).to.be.true;
+		expect( schema.checkAtPosition( { name: '$inline', attribute: 'bold' }, new Position( root, [ 0, 0 ] ) ) ).to.be.true;
+		expect( schema.checkAtPosition( { name: '$inline', attribute: 'bold' }, new Position( root, [ 2, 0 ] ) ) ).to.be.true;
 
 		// Header is allowed in DIV.
 		expect( schema.checkAtPosition( { name: 'header' }, new Position( root, [ 0, 0 ] ) ) ).to.be.true;
@@ -181,14 +181,14 @@ describe( 'checkAtPosition', () => {
 
 	it( 'should return false if given element is not allowed by schema at given position', () => {
 		// Inline is not allowed in root.
-		expect( schema.checkAtPosition( { name: 'inline' }, new Position( root, [ 0 ] ) ) ).to.be.false;
+		expect( schema.checkAtPosition( { name: '$inline' }, new Position( root, [ 0 ] ) ) ).to.be.false;
 
 		// P with attribute is not allowed anywhere.
 		expect( schema.checkAtPosition( { name: 'p', attribute: 'bold' }, new Position( root, [ 0 ] ) ) ).to.be.false;
 		expect( schema.checkAtPosition( { name: 'p', attribute: 'bold' }, new Position( root, [ 0, 0 ] ) ) ).to.be.false;
 
 		// Bold text is not allowed in header
-		expect( schema.checkAtPosition( { name: 'inline', attribute: 'bold' }, new Position( root, [ 1, 0 ] ) ) ).to.be.false;
+		expect( schema.checkAtPosition( { name: '$inline', attribute: 'bold' }, new Position( root, [ 1, 0 ] ) ) ).to.be.false;
 	} );
 
 	it( 'should return false if given element is not registered in schema', () => {
@@ -202,6 +202,6 @@ describe( 'checkForPath', () => {
 	} );
 
 	it( 'should handle path given as string', () => {
-		expect( schema.checkForPath( { name: 'inline' }, 'block root' ) ).to.be.true;
+		expect( schema.checkForPath( { name: '$inline' }, '$block $root' ) ).to.be.true;
 	} );
 } );

+ 6 - 6
packages/ckeditor5-engine/tests/schema/schemaitem.js → packages/ckeditor5-engine/tests/treemodel/schema/schemaitem.js

@@ -14,12 +14,12 @@ let schema, item;
 beforeEach( () => {
 	schema = new Schema();
 
-	schema.registerItem( 'p', 'block' );
-	schema.registerItem( 'header', 'block' );
-	schema.registerItem( 'div', 'block' );
-	schema.registerItem( 'html', 'block' );
-	schema.registerItem( 'span', 'inline' );
-	schema.registerItem( 'image', 'inline' );
+	schema.registerItem( 'p', '$block' );
+	schema.registerItem( 'header', '$block' );
+	schema.registerItem( 'div', '$block' );
+	schema.registerItem( 'html', '$block' );
+	schema.registerItem( 'span', '$inline' );
+	schema.registerItem( 'image', '$inline' );
 
 	item = new SchemaItem( schema );
 } );