normalizetoolbarconfig.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 normalizeToolbarConfig from '../../src/toolbar/normalizetoolbarconfig';
  6. describe( 'normalizeToolbarConfig()', () => {
  7. it( 'normalizes the config specified as an Array', () => {
  8. const cfg = [ 'foo', 'bar' ];
  9. const normalized = normalizeToolbarConfig( cfg );
  10. expect( normalized ).to.be.an( 'object' );
  11. expect( normalized.items ).to.deep.equal( cfg );
  12. } );
  13. it( 'passes through an already normalized config', () => {
  14. const cfg = {
  15. items: [ 'foo', 'bar' ],
  16. foo: 'bar'
  17. };
  18. const normalized = normalizeToolbarConfig( cfg );
  19. expect( normalized ).to.deep.equal( cfg );
  20. } );
  21. it( 'adds missing items property', () => {
  22. const cfg = {
  23. foo: 'bar'
  24. };
  25. const normalized = normalizeToolbarConfig( cfg );
  26. expect( normalized ).to.deep.equal( {
  27. items: [],
  28. foo: 'bar'
  29. } );
  30. expect( normalized ).to.not.equal( cfg ); // Make sure we don't modify an existing obj.
  31. } );
  32. it( 'returns an empty config if config is not defined', () => {
  33. const normalized = normalizeToolbarConfig();
  34. expect( normalized ).to.be.an( 'object' );
  35. expect( normalized.items ).to.be.an( 'array' ).of.length( 0 );
  36. } );
  37. } );