utils.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import { normalizeOptions } from '../../src/fontsize/utils';
  6. describe( 'FontSizeEditing Utils', () => {
  7. describe( 'normalizeOptions()', () => {
  8. it( 'should discard unsupported values', () => {
  9. expect( normalizeOptions( [ () => {}, 'default', 'unknown' ] ) ).to.deep.equal( [ { title: 'Default', model: undefined } ] );
  10. } );
  11. it( 'should pass through object definition', () => {
  12. expect( normalizeOptions( [ {
  13. title: 'My Size',
  14. model: 'my-size',
  15. view: { name: 'span', styles: 'font-size: 12em;' }
  16. } ] ) ).to.deep.equal( [
  17. {
  18. title: 'My Size',
  19. model: 'my-size',
  20. view: { name: 'span', styles: 'font-size: 12em;' }
  21. }
  22. ] );
  23. } );
  24. describe( 'named presets', () => {
  25. it( 'should return defined presets', () => {
  26. expect( normalizeOptions( [ 'tiny', 'small', 'default', 'big', 'huge' ] ) ).to.deep.equal( [
  27. { title: 'Tiny', model: 'tiny', view: { name: 'span', classes: 'text-tiny', priority: 5 } },
  28. { title: 'Small', model: 'small', view: { name: 'span', classes: 'text-small', priority: 5 } },
  29. { title: 'Default', model: undefined },
  30. { title: 'Big', model: 'big', view: { name: 'span', classes: 'text-big', priority: 5 } },
  31. { title: 'Huge', model: 'huge', view: { name: 'span', classes: 'text-huge', priority: 5 } }
  32. ] );
  33. } );
  34. } );
  35. describe( 'numerical presets', () => {
  36. it( 'should return generated presets', () => {
  37. expect( normalizeOptions( [ '10', 12, 'default', '14.1', 18.3 ] ) ).to.deep.equal( [
  38. { title: '10', model: 10, view: { name: 'span', styles: { 'font-size': '10px' }, priority: 5 } },
  39. { title: '12', model: 12, view: { name: 'span', styles: { 'font-size': '12px' }, priority: 5 } },
  40. { title: 'Default', model: undefined },
  41. { title: '14.1', model: 14.1, view: { name: 'span', styles: { 'font-size': '14.1px' }, priority: 5 } },
  42. { title: '18.3', model: 18.3, view: { name: 'span', styles: { 'font-size': '18.3px' }, priority: 5 } }
  43. ] );
  44. } );
  45. } );
  46. } );
  47. } );