浏览代码

Add unit test for util generator.

Mateusz Samsel 6 年之前
父节点
当前提交
27a6d3acd1
共有 1 个文件被更改,包括 38 次插入0 次删除
  1. 38 0
      packages/ckeditor5-enter/tests/utils.js

+ 38 - 0
packages/ckeditor5-enter/tests/utils.js

@@ -0,0 +1,38 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import { getCopyOnEnterAttributes } from '../src/utils';
+import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
+
+describe( 'utils', () => {
+	describe( 'getCopyOnEnterAttributes()', () => {
+		it( 'filters attributes with copyOnEnter property', () => {
+			return ModelTestEditor.create()
+				.then( editor => {
+					const schema = editor.model.schema;
+
+					schema.register( 'foo', { inheritAllFrom: '$block' } );
+					schema.register( 'bar', { inheritAllFrom: '$block' } );
+					schema.register( 'baz', { inheritAllFrom: '$block' } );
+
+					schema.setAttributeProperties( 'foo', { copyOnEnter: true } );
+					schema.setAttributeProperties( 'baz', { copyOnEnter: true } );
+
+					const allAttributes = ( new Map( [
+						[ 'foo', true ],
+						[ 'bar', true ],
+						[ 'baz', true ]
+					] ) )[ Symbol.iterator ]();
+
+					expect( Array.from( getCopyOnEnterAttributes( schema, allAttributes ) ) ).to.deep.equal(
+						[
+							[ 'foo', true ],
+							[ 'baz', true ]
+						]
+					);
+				} );
+		} );
+	} );
+} );