utils.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import { getCopyOnEnterAttributes } from '../src/utils';
  6. import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
  7. describe( 'utils', () => {
  8. describe( 'getCopyOnEnterAttributes()', () => {
  9. it( 'filters attributes with copyOnEnter property', () => {
  10. return ModelTestEditor.create()
  11. .then( editor => {
  12. const schema = editor.model.schema;
  13. schema.extend( '$text', {
  14. allowAttributes: [ 'foo', 'bar', 'baz' ]
  15. } );
  16. schema.setAttributeProperties( 'foo', { copyOnEnter: true } );
  17. schema.setAttributeProperties( 'baz', { copyOnEnter: true } );
  18. const allAttributes = ( new Map( [
  19. [ 'foo', true ],
  20. [ 'bar', true ],
  21. [ 'baz', true ]
  22. ] ) )[ Symbol.iterator ]();
  23. expect( Array.from( getCopyOnEnterAttributes( schema, allAttributes ) ) ).to.deep.equal(
  24. [
  25. [ 'foo', true ],
  26. [ 'baz', true ]
  27. ]
  28. );
  29. } );
  30. } );
  31. } );
  32. } );