8
0

background.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @license Copyright (c) 2003-2020, 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 { addBackgroundRules } from '../../../src/view/styles/background';
  7. describe( 'Background styles normalization', () => {
  8. let styles;
  9. before( () => {
  10. const stylesProcessor = new StylesProcessor();
  11. StylesMap._setProcessor( stylesProcessor );
  12. addBackgroundRules( stylesProcessor );
  13. } );
  14. beforeEach( () => {
  15. styles = new StylesMap();
  16. } );
  17. it( 'should normalize background', () => {
  18. // TODO: border-box given only for coverage test.
  19. styles.setTo( 'background:url("example.jpg") center #f00 repeat-y fixed border-box;' );
  20. expect( styles.getNormalized( 'background' ) ).to.deep.equal( {
  21. attachment: 'fixed',
  22. image: 'url("example.jpg")',
  23. position: [ 'center' ],
  24. repeat: [ 'repeat-y' ],
  25. color: '#f00'
  26. } );
  27. } );
  28. // TODO: define what should happen with layers
  29. it.skip( 'should normalize background with layers', () => {
  30. styles.setTo( 'background:url("test.jpg") repeat-y,#f00;' );
  31. expect( styles.getNormalized( 'background' ) ).to.deep.equal( { color: '#f00' } );
  32. } );
  33. it( 'should normalize background-color', () => {
  34. styles.setTo( 'background-color:#f00;' );
  35. expect( styles.getNormalized( 'background' ) ).to.deep.equal( { color: '#f00' } );
  36. } );
  37. it( 'should output inline background-color style', () => {
  38. styles.setTo( 'background:#f00;' );
  39. expect( styles.toString() ).to.equal( 'background-color:#f00;' );
  40. expect( styles.getAsString( 'background-color' ) ).to.equal( '#f00' );
  41. } );
  42. } );