8
0

paddingstyles.js 2.0 KB

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