backgroundstyles.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 { addBackgroundStylesProcessor } from '../../../src/view/styles/backgroundstyles';
  7. describe( 'Background styles normalization', () => {
  8. let styles;
  9. beforeEach( () => {
  10. const stylesProcessor = new StylesProcessor();
  11. addBackgroundStylesProcessor( stylesProcessor );
  12. styles = new Styles( stylesProcessor );
  13. } );
  14. it( 'should normalize background', () => {
  15. // TODO: border-box given only for coverage test.
  16. styles.setStyle( 'background:url("example.jpg") center #f00 repeat-y fixed border-box;' );
  17. expect( styles.getNormalized( 'background' ) ).to.deep.equal( {
  18. attachment: 'fixed',
  19. image: 'url("example.jpg")',
  20. position: [ 'center' ],
  21. repeat: [ 'repeat-y' ],
  22. color: '#f00'
  23. } );
  24. } );
  25. // TODO: define what should happen with layers
  26. it.skip( 'should normalize background with layers', () => {
  27. styles.setStyle( 'background:url("test.jpg") repeat-y,#f00;' );
  28. expect( styles.getNormalized( 'background' ) ).to.deep.equal( { color: '#f00' } );
  29. } );
  30. it( 'should normalize background-color', () => {
  31. styles.setStyle( 'background-color:#f00;' );
  32. expect( styles.getNormalized( 'background' ) ).to.deep.equal( { color: '#f00' } );
  33. } );
  34. it( 'should output inline background-color style', () => {
  35. styles.setStyle( 'background:#f00;' );
  36. expect( styles.getInlineStyle() ).to.equal( 'background-color:#f00;' );
  37. expect( styles.getInlineProperty( 'background-color' ) ).to.equal( '#f00' );
  38. } );
  39. } );