restricteddocument.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import testUtils from './_utils/utils';
  6. import VirtualTestEditor from './_utils/virtualtesteditor';
  7. import RestrictedDocument from './../src/restricteddocument';
  8. describe( 'RestrictedDocument', () => {
  9. let editor;
  10. testUtils.createSinonSandbox();
  11. beforeEach( () => {
  12. return VirtualTestEditor
  13. .create( { plugins: [ RestrictedDocument ] } )
  14. .then( newEditor => {
  15. editor = newEditor;
  16. } );
  17. } );
  18. afterEach( () => {
  19. if ( editor ) {
  20. return editor.destroy();
  21. }
  22. } );
  23. it( 'should be named', () => {
  24. expect( RestrictedDocument.pluginName ).to.equal( 'RestrictedDocument' );
  25. } );
  26. it( 'should be loaded', () => {
  27. expect( editor.plugins.get( 'RestrictedDocument' ) ).to.be.instanceOf( RestrictedDocument );
  28. } );
  29. it( 'should set proper schema rules', () => {
  30. const model = editor.model;
  31. expect( model.schema.checkAttribute( [ '$root', '$text' ], 'nonRestricted' ) ).to.be.true;
  32. expect( model.schema.checkAttribute( [ '$block', '$text' ], 'nonRestricted' ) ).to.be.true;
  33. expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'nonRestricted' ) ).to.be.true;
  34. expect( model.schema.checkAttribute( [ '$block' ], 'nonRestricted' ) ).to.be.false;
  35. } );
  36. } );