mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
import postcss from 'postcss'
|
|
import path from 'path'
|
|
import tailwind from '../../src/jit/index.js'
|
|
|
|
function run(input, config = {}) {
|
|
const { currentTestName } = expect.getState()
|
|
|
|
return postcss(tailwind(config)).process(input, {
|
|
from: `${path.resolve(__filename)}?test=${currentTestName}`,
|
|
})
|
|
}
|
|
|
|
test('PHP arrays', async () => {
|
|
let config = {
|
|
mode: 'jit',
|
|
purge: [
|
|
{
|
|
raw: `<h1 class="<?php echo wrap(['class' => "max-w-[16rem]"]); ?>">Hello world</h1>`,
|
|
},
|
|
],
|
|
theme: {},
|
|
plugins: [],
|
|
}
|
|
|
|
let css = `@tailwind utilities`
|
|
|
|
return run(css, config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(`
|
|
.max-w-\\[16rem\\] {
|
|
max-width: 16rem;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('arbitrary values with quotes', async () => {
|
|
let config = {
|
|
mode: 'jit',
|
|
purge: [
|
|
{
|
|
raw: `<div class="content-['hello]']"></div>`,
|
|
},
|
|
],
|
|
theme: {},
|
|
plugins: [],
|
|
}
|
|
|
|
let css = `@tailwind utilities`
|
|
|
|
return run(css, config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(`
|
|
.content-\\[\\'hello\\]\\'\\] {
|
|
content: 'hello]';
|
|
}
|
|
`)
|
|
})
|
|
})
|