8
0

paddingstyles.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. import StylesMap, { StylesProcessor } from '../../../src/view/stylesmap';
  6. import { addPaddingRules } from '../../../src/view/styles/padding';
  7. describe( 'Padding styles normalization', () => {
  8. let styles;
  9. before( () => {
  10. const stylesProcessor = new StylesProcessor();
  11. StylesMap._setProcessor( stylesProcessor );
  12. addPaddingRules( stylesProcessor );
  13. } );
  14. beforeEach( () => {
  15. styles = new StylesMap();
  16. } );
  17. it( 'should set all paddings (1 value defined)', () => {
  18. styles.setTo( 'padding:1px;' );
  19. expect( styles.getNormalized( 'padding' ) ).to.deep.equal( {
  20. top: '1px',
  21. right: '1px',
  22. bottom: '1px',
  23. left: '1px'
  24. } );
  25. } );
  26. it( 'should set all paddings (2 values defined)', () => {
  27. styles.setTo( 'padding:1px .34cm;' );
  28. expect( styles.getNormalized( 'padding' ) ).to.deep.equal( {
  29. top: '1px',
  30. right: '.34cm',
  31. bottom: '1px',
  32. left: '.34cm'
  33. } );
  34. } );
  35. it( 'should set all paddings (3 values defined)', () => {
  36. styles.setTo( 'padding:1px .34cm 90.1rem;' );
  37. expect( styles.getNormalized( 'padding' ) ).to.deep.equal( {
  38. top: '1px',
  39. right: '.34cm',
  40. bottom: '90.1rem',
  41. left: '.34cm'
  42. } );
  43. } );
  44. it( 'should set all paddings (4 values defined)', () => {
  45. styles.setTo( 'padding:1px .34cm 90.1rem thick;' );
  46. expect( styles.getNormalized( 'padding' ) ).to.deep.equal( {
  47. top: '1px',
  48. right: '.34cm',
  49. bottom: '90.1rem',
  50. left: 'thick'
  51. } );
  52. } );
  53. describe( 'padding-*', () => {
  54. it( 'should set proper padding', () => {
  55. styles.setTo( 'padding-top:1px;' );
  56. expect( styles.getNormalized( 'padding' ) ).to.deep.equal( {
  57. top: '1px'
  58. } );
  59. } );
  60. it( 'should set proper padding with padding shorthand', () => {
  61. styles.setTo( 'padding: 2em;padding-top:1px;' );
  62. expect( styles.getNormalized( 'padding' ) ).to.deep.equal( {
  63. top: '1px',
  64. right: '2em',
  65. bottom: '2em',
  66. left: '2em'
  67. } );
  68. } );
  69. } );
  70. } );