- Setup the codebase to be able to use the Rust parts based on an environment variable: `OXIDE=1`. - Setup some tests that run both the non-Rust and Rust version in the same test. - Sort the candidates in a consistent way, to guarantee the order for now (especially in tests). - Reflect sorting related changes in tests. - Ensure tests run in both the Rust and non-Rust version. (Some tests are explicitly skipped when using the Rust version since we haven't implemented those features yet. These include: custom prefix, transformers and extractors). - `jest` -`OXIDE=1 jest`
83 lines
1.8 KiB
JavaScript
83 lines
1.8 KiB
JavaScript
import path from 'path'
|
|
|
|
import { run } from './util/run'
|
|
import { env } from '../src/lib/sharedState'
|
|
|
|
let css = String.raw
|
|
|
|
let t = env.OXIDE ? test.skip : test
|
|
|
|
t('it detects svelte based on the file extension', () => {
|
|
let config = {
|
|
content: [path.resolve(__dirname, './syntax-svelte.test.svelte')],
|
|
corePlugins: { preflight: false },
|
|
theme: {},
|
|
plugins: [],
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind components;
|
|
@tailwind utilities;
|
|
`
|
|
|
|
return run(input, config).then((result) => {
|
|
expect(result.css).toMatchCss(css`
|
|
.bg-red-500 {
|
|
--tw-bg-opacity: 1;
|
|
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
|
|
}
|
|
@media (min-width: 1024px) {
|
|
.lg\:hover\:bg-blue-500:hover {
|
|
--tw-bg-opacity: 1;
|
|
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
}
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
t('using raw with svelte extension', () => {
|
|
let config = {
|
|
content: [
|
|
{
|
|
raw: `
|
|
<script>
|
|
let current = 'foo'
|
|
</script>
|
|
|
|
<button class:lg:hover:bg-blue-500={current === 'foo'}>Click me</button>
|
|
|
|
<button
|
|
class:bg-red-500={current === 'foo'}
|
|
>
|
|
Click me
|
|
</button>
|
|
`,
|
|
extension: 'svelte',
|
|
},
|
|
],
|
|
corePlugins: { preflight: false },
|
|
theme: {},
|
|
plugins: [],
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind components;
|
|
@tailwind utilities;
|
|
`
|
|
|
|
return run(input, config).then((result) => {
|
|
expect(result.css).toMatchCss(css`
|
|
.bg-red-500 {
|
|
--tw-bg-opacity: 1;
|
|
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
|
|
}
|
|
@media (min-width: 1024px) {
|
|
.lg\:hover\:bg-blue-500:hover {
|
|
--tw-bg-opacity: 1;
|
|
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
}
|
|
}
|
|
`)
|
|
})
|
|
})
|