/
githubmirror
/
tailwindcss
Обзор
Документация
Войти
/
githubmirror
/
tailwindcss
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v3.4.18
tests/parallel-variants.test.js
136 строк
3 KB
Robin Malfait
Cleanup oxide — Part #2 (#13312)
22 мар 2024, 19:12
Не верифицирован
22 мар 2024, 19:12
44b3b42
Код
Авторство
О чём код?
import { run, html, css } from './util/run' test('basic parallel variants', async () => { let config = { content: [ { raw: html`<div class="hover:test:font-black test:font-bold test:font-medium font-normal" ></div>`, }, ], plugins: [ function test({ addVariant }) { addVariant('test', ['& *::test', '&::test']) }, ], } return run('@tailwind utilities', config).then((result) => { expect(result.css).toMatchFormattedCss(css` .font-normal { font-weight: 400; } .test\:font-bold ::test { font-weight: 700; } .test\:font-medium ::test { font-weight: 500; } .hover\:test\:font-black ::test:hover { font-weight: 900; } .test\:font-bold::test { font-weight: 700; } .test\:font-medium::test { font-weight: 500; } .hover\:test\:font-black::test:hover { font-weight: 900; } `) }) }) test('parallel variants can be generated using a function that returns parallel variants', async () => { let config = { content: [ { raw: html`<div class="hover:test:font-black test:font-bold test:font-medium font-normal" ></div>`, }, ], plugins: [ function test({ addVariant }) { addVariant('test', () => ['& *::test', '&::test']) }, ], } return run('@tailwind utilities', config).then((result) => { expect(result.css).toMatchFormattedCss(css` .font-normal { font-weight: 400; } .test\:font-bold ::test { font-weight: 700; } .test\:font-medium ::test { font-weight: 500; } .test\:font-bold::test { font-weight: 700; } .test\:font-medium::test { font-weight: 500; } .hover\:test\:font-black ::test:hover { font-weight: 900; } .hover\:test\:font-black::test:hover { font-weight: 900; } `) }) }) test('a function that returns parallel variants can modify the container', async () => { let config = { content: [ { raw: html`<div class="hover:test:font-black test:font-bold test:font-medium font-normal" ></div>`, }, ], plugins: [ function test({ addVariant }) { addVariant('test', ({ container }) => { container.walkDecls((decl) => { decl.value = `calc(0 + ${decl.value})` }) return ['& *::test', '&::test'] }) }, ], } return run('@tailwind utilities', config).then((result) => { expect(result.css).toMatchFormattedCss(css` .font-normal { font-weight: 400; } .test\:font-bold ::test { font-weight: 700; } .test\:font-medium ::test { font-weight: 500; } .test\:font-bold::test { font-weight: 700; } .test\:font-medium::test { font-weight: 500; } .hover\:test\:font-black ::test:hover { font-weight: 900; } .hover\:test\:font-black::test:hover { font-weight: 900; } `) }) })