8
0

utils.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/fontfamily/utils';
  6. describe( 'FontFamily utils', () => {
  7. describe( 'normalizeOptions()', () => {
  8. it( 'should discard unsupported values', () => {
  9. expect( normalizeOptions( [ () => {}, 0, true ] ) ).to.deep.equal( [] );
  10. } );
  11. it( 'should pass through object definition', () => {
  12. expect( normalizeOptions( [
  13. 'default',
  14. {
  15. title: 'Comic Sans',
  16. model: 'comic',
  17. view: {
  18. name: 'span',
  19. styles: {
  20. 'font-family': 'Comic Sans'
  21. }
  22. }
  23. }
  24. ] ) ).to.deep.equal( [
  25. {
  26. model: undefined,
  27. title: 'Default'
  28. },
  29. {
  30. title: 'Comic Sans',
  31. model: 'comic',
  32. view: {
  33. name: 'span',
  34. styles: {
  35. 'font-family': 'Comic Sans'
  36. }
  37. }
  38. }
  39. ] );
  40. } );
  41. describe( 'shorthand presets', () => {
  42. it( 'should return full preset from string presets', () => {
  43. expect( normalizeOptions( ( [
  44. 'Arial',
  45. '"Comic Sans MS", sans-serif',
  46. 'Lucida Console, \'Courier New\', Courier, monospace'
  47. ] ) ) ).to.deep.equal( [
  48. {
  49. title: 'Arial',
  50. model: 'Arial',
  51. view: {
  52. name: 'span',
  53. styles: {
  54. 'font-family': 'Arial'
  55. }
  56. }
  57. },
  58. {
  59. title: 'Comic Sans MS',
  60. model: 'Comic Sans MS',
  61. view: {
  62. name: 'span',
  63. styles: {
  64. 'font-family': '\'Comic Sans MS\', sans-serif'
  65. }
  66. }
  67. },
  68. {
  69. title: 'Lucida Console',
  70. model: 'Lucida Console',
  71. view: {
  72. name: 'span',
  73. styles: {
  74. 'font-family': '\'Lucida Console\', \'Courier New\', Courier, monospace'
  75. }
  76. }
  77. }
  78. ] );
  79. } );
  80. } );
  81. } );
  82. } );