normalizeProp.spec.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { normalizeClass, parseStringStyle } from '../src'
  2. describe('normalizeClass', () => {
  3. test('handles string correctly', () => {
  4. expect(normalizeClass('foo')).toEqual('foo')
  5. })
  6. test('handles array correctly', () => {
  7. expect(normalizeClass(['foo', undefined, true, false, 'bar'])).toEqual(
  8. 'foo bar'
  9. )
  10. })
  11. test('handles object correctly', () => {
  12. expect(normalizeClass({ foo: true, bar: false, baz: true })).toEqual(
  13. 'foo baz'
  14. )
  15. })
  16. // #6777
  17. test('parse multi-line inline style', () => {
  18. expect(
  19. parseStringStyle(`border: 1px solid transparent;
  20. background: linear-gradient(white, white) padding-box,
  21. repeating-linear-gradient(
  22. -45deg,
  23. #ccc 0,
  24. #ccc 0.5em,
  25. white 0,
  26. white 0.75em
  27. );`)
  28. ).toMatchInlineSnapshot(`
  29. {
  30. "background": "linear-gradient(white, white) padding-box,
  31. repeating-linear-gradient(
  32. -45deg,
  33. #ccc 0,
  34. #ccc 0.5em,
  35. white 0,
  36. white 0.75em
  37. )",
  38. "border": "1px solid transparent",
  39. }
  40. `)
  41. })
  42. })