specialcharacterstext.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. /* globals document */
  6. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  7. import SpecialCharacters from '../src/specialcharacters';
  8. import SpecialCharactersText from '../src/specialcharacterstext';
  9. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  10. describe( 'SpecialCharactersText', () => {
  11. testUtils.createSinonSandbox();
  12. let addItemsSpy, addItemsFirstCallArgs;
  13. beforeEach( () => {
  14. const editorElement = document.createElement( 'div' );
  15. addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );
  16. document.body.appendChild( editorElement );
  17. return ClassicTestEditor
  18. .create( editorElement, {
  19. plugins: [ SpecialCharacters, SpecialCharactersText ]
  20. } )
  21. .then( () => {
  22. addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
  23. } );
  24. } );
  25. afterEach( () => {
  26. addItemsSpy.restore();
  27. } );
  28. it( 'adds new items', () => {
  29. expect( addItemsSpy.callCount ).to.equal( 1 );
  30. } );
  31. it( 'properly names the category', () => {
  32. expect( addItemsFirstCallArgs[ 0 ] ).to.be.equal( 'Text' );
  33. } );
  34. it( 'adds proper characters', () => {
  35. expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
  36. character: '…',
  37. title: 'Horizontal ellipsis'
  38. } );
  39. expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
  40. character: '“',
  41. title: 'Left double quotation mark'
  42. } );
  43. } );
  44. } );