8
0

paddingstyles.js 1.8 KB

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