utils.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 { isColor, isLineStyle } from '../../../src/view/styles/utils';
  6. describe( 'Styles utils', () => {
  7. describe( 'isColor()', () => {
  8. it( 'returns true for #RGB color', () => {
  9. testValues( [ '#f00', '#ba2' ], isColor );
  10. } );
  11. it( 'returns true for #RRGGBB color', () => {
  12. testValues( [ '#ff0000', '#bbaa22' ], isColor );
  13. } );
  14. it( 'returns true for #RGBA color', () => {
  15. testValues( [ '#f000', '#ba24' ], isColor );
  16. } );
  17. it( 'returns true for #RRGGBBAA color', () => {
  18. testValues( [ '#ff000000', '#bbaa2244' ], isColor );
  19. } );
  20. it( 'returns true for rgb() color', () => {
  21. testValues( [ 'rgb(255, 255, 255)', 'rgb(23%,0,100%)' ], isColor );
  22. } );
  23. it( 'returns true for rgba() color', () => {
  24. testValues( [ 'rgba(1,2,3,0.7)', 'rgba(12%,0,0,1)' ], isColor );
  25. } );
  26. it( 'returns true for hsl() color', () => {
  27. testValues( [ 'hsl(0, 100%, 50%)', 'hsl(340,80%,40%)' ], isColor );
  28. } );
  29. it( 'returns true for hsla() color', () => {
  30. testValues( [ 'hsla(240, 100%, 50%, 1)', 'hsla(240, 100%, 50%, .05)' ], isColor );
  31. } );
  32. it( 'returns true for currentColor color', () => {
  33. testValues( [ 'currentColor' ], isColor );
  34. } );
  35. } );
  36. describe( 'isLineStyle()', () => {
  37. it( 'returns true for line style', () => {
  38. testValues(
  39. [ 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' ],
  40. isLineStyle
  41. );
  42. } );
  43. } );
  44. describe( 'isLength()', () => {
  45. it( 'returns true for named widths', () => {
  46. testValues(
  47. [ 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' ],
  48. isLineStyle
  49. );
  50. } );
  51. } );
  52. describe( 'isRepeat()', () => {} );
  53. describe( 'isPosition()', () => {} );
  54. function testValues( values, callback ) {
  55. values.map( string => expect( callback( string ), string ).to.be.true );
  56. }
  57. } );