8
0

editor-base.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: editor */
  6. 'use strict';
  7. import Editor from '/ckeditor5/editor/editor.js';
  8. import Command from '/ckeditor5/command/command.js';
  9. import Locale from '/ckeditor5/utils/locale.js';
  10. import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
  11. describe( 'Editor', () => {
  12. describe( 'locale', () => {
  13. it( 'is instantiated and t() is exposed', () => {
  14. const editor = new Editor();
  15. expect( editor.locale ).to.be.instanceof( Locale );
  16. expect( editor.t ).to.equal( editor.locale.t );
  17. } );
  18. it( 'is configured with the config.lang', () => {
  19. const editor = new Editor( { lang: 'pl' } );
  20. expect( editor.locale.lang ).to.equal( 'pl' );
  21. } );
  22. } );
  23. describe( 'destroy', () => {
  24. it( 'should fire "destroy"', () => {
  25. const editor = new Editor();
  26. let spy = sinon.spy();
  27. editor.on( 'destroy', spy );
  28. return editor.destroy().then( () => {
  29. expect( spy.calledOnce ).to.be.true;
  30. } );
  31. } );
  32. } );
  33. describe( 'execute', () => {
  34. it( 'should execute specified command', () => {
  35. const editor = new Editor();
  36. let command = new Command( editor );
  37. sinon.spy( command, '_execute' );
  38. editor.commands.set( 'commandName', command );
  39. editor.execute( 'commandName' );
  40. expect( command._execute.calledOnce ).to.be.true;
  41. } );
  42. it( 'should throw an error if specified command has not been added', () => {
  43. const editor = new Editor();
  44. expect( () => {
  45. editor.execute( 'command' );
  46. } ).to.throw( CKEditorError, /^editor-command-not-found:/ );
  47. } );
  48. } );
  49. } );