|
| 1 | +import { normalize } from '../src/util/dataTypes' |
| 2 | + |
| 3 | +let table = [ |
| 4 | + ['foo', 'foo'], |
| 5 | + ['foo-bar', 'foo-bar'], |
| 6 | + ['16/9', '16 / 9'], |
| 7 | + |
| 8 | + // '_'s are converted to spaces except when escaped |
| 9 | + ['foo_bar', 'foo bar'], |
| 10 | + ['foo__bar', 'foo bar'], |
| 11 | + ['foo\\_bar', 'foo_bar'], |
| 12 | + |
| 13 | + // Urls are preserved as-is |
| 14 | + [ |
| 15 | + 'url("https://example.com/abc+def/some-path/2022-01-01-abc/some_underscoered_path")', |
| 16 | + 'url("https://example.com/abc+def/some-path/2022-01-01-abc/some_underscoered_path")', |
| 17 | + ], |
| 18 | + |
| 19 | + // var(…) is preserved as is |
| 20 | + ['var(--foo)', 'var(--foo)'], |
| 21 | + ['var(--headings-h1-size)', 'var(--headings-h1-size)'], |
| 22 | + |
| 23 | + // calc(…) get's spaces around operators |
| 24 | + ['calc(1+2)', 'calc(1 + 2)'], |
| 25 | + ['calc(100%+1rem)', 'calc(100% + 1rem)'], |
| 26 | + ['calc(var(--headings-h1-size)*100)', 'calc(var(--headings-h1-size) * 100)'], |
| 27 | + [ |
| 28 | + 'calc(var(--headings-h1-size)*calc(100%+50%))', |
| 29 | + 'calc(var(--headings-h1-size) * calc(100% + 50%))', |
| 30 | + ], |
| 31 | + ['var(--heading-h1-font-size)', 'var(--heading-h1-font-size)'], |
| 32 | + ['var(--my-var-with-more-than-3-words)', 'var(--my-var-with-more-than-3-words)'], |
| 33 | + ['var(--width, calc(100%+1rem))', 'var(--width, calc(100% + 1rem))'], |
| 34 | + |
| 35 | + // Misc |
| 36 | + ['color(0_0_0/1.0)', 'color(0 0 0 / 1.0)'], |
| 37 | +] |
| 38 | + |
| 39 | +it.each(table)('normalize data: %s', (input, output) => { |
| 40 | + expect(normalize(input)).toBe(output) |
| 41 | +}) |
0 commit comments