8
0

mentionediting.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import MentionEditing from '../src/mentionediting';
  7. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  8. describe( 'MentionEditing', () => {
  9. testUtils.createSinonSandbox();
  10. it( 'should be named', () => {
  11. expect( MentionEditing.pluginName ).to.equal( 'MentionEditing' );
  12. } );
  13. describe( 'init()', () => {
  14. it( 'should be loaded', () => {
  15. return createTestEditor()
  16. .then( newEditor => {
  17. expect( newEditor.plugins.get( MentionEditing ) ).to.be.instanceOf( MentionEditing );
  18. } );
  19. } );
  20. it( 'should set proper schema rules', () => {
  21. return createTestEditor()
  22. .then( newEditor => {
  23. const model = newEditor.model;
  24. expect( model.schema.checkAttribute( [ '$root', '$text' ], 'mention' ) ).to.be.true;
  25. expect( model.schema.checkAttribute( [ '$block', '$text' ], 'mention' ) ).to.be.true;
  26. expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'mention' ) ).to.be.true;
  27. expect( model.schema.checkAttribute( [ '$block' ], 'mention' ) ).to.be.false;
  28. } );
  29. } );
  30. } );
  31. function createTestEditor( mentionConfig ) {
  32. return VirtualTestEditor
  33. .create( {
  34. plugins: [ MentionEditing ],
  35. mention: mentionConfig
  36. } );
  37. }
  38. } );