|
| 1 | +import { candidate, css, html, js, json, test } from '../utils' |
| 2 | + |
| 3 | +test( |
| 4 | + 'builds the `@headlessui/tailwindcss` plugin utilities (CJS)', |
| 5 | + { |
| 6 | + fs: { |
| 7 | + 'package.json': json` |
| 8 | + { |
| 9 | + "type": "commonjs", |
| 10 | + "dependencies": { |
| 11 | + "postcss": "^8", |
| 12 | + "postcss-cli": "^10", |
| 13 | + "tailwindcss": "workspace:^", |
| 14 | + "@tailwindcss/postcss": "workspace:^", |
| 15 | + "@headlessui/tailwindcss": "^0.2.1" |
| 16 | + } |
| 17 | + } |
| 18 | + `, |
| 19 | + 'postcss.config.cjs': js` |
| 20 | + let tailwindcss = require('@tailwindcss/postcss') |
| 21 | + module.exports = { |
| 22 | + plugins: [tailwindcss()], |
| 23 | + } |
| 24 | + `, |
| 25 | + 'index.html': html` |
| 26 | + <div className="ui-open:flex"></div> |
| 27 | + `, |
| 28 | + 'src/index.css': css` |
| 29 | + @import 'tailwindcss/theme' theme(reference); |
| 30 | + @import 'tailwindcss/utilities'; |
| 31 | + @plugin '@headlessui/tailwindcss'; |
| 32 | + `, |
| 33 | + }, |
| 34 | + }, |
| 35 | + async ({ fs, exec }) => { |
| 36 | + await exec('pnpm postcss src/index.css --output dist/out.css') |
| 37 | + |
| 38 | + await fs.expectFileToContain('dist/out.css', [candidate`ui-open:flex`]) |
| 39 | + }, |
| 40 | +) |
| 41 | + |
| 42 | +test( |
| 43 | + 'builds the `@headlessui/tailwindcss` plugin utilities (ESM)', |
| 44 | + { |
| 45 | + fs: { |
| 46 | + 'package.json': json` |
| 47 | + { |
| 48 | + "type": "module", |
| 49 | + "dependencies": { |
| 50 | + "postcss": "^8", |
| 51 | + "postcss-cli": "^10", |
| 52 | + "tailwindcss": "workspace:^", |
| 53 | + "@tailwindcss/postcss": "workspace:^", |
| 54 | + "@headlessui/tailwindcss": "^0.2.1" |
| 55 | + } |
| 56 | + } |
| 57 | + `, |
| 58 | + 'postcss.config.mjs': js` |
| 59 | + import tailwindcss from '@tailwindcss/postcss' |
| 60 | + export default { |
| 61 | + plugins: [tailwindcss()], |
| 62 | + } |
| 63 | + `, |
| 64 | + 'index.html': html` |
| 65 | + <div className="ui-open:flex"></div> |
| 66 | + `, |
| 67 | + 'src/index.css': css` |
| 68 | + @import 'tailwindcss/theme' theme(reference); |
| 69 | + @import 'tailwindcss/utilities'; |
| 70 | + @plugin '@headlessui/tailwindcss'; |
| 71 | + `, |
| 72 | + }, |
| 73 | + }, |
| 74 | + async ({ fs, exec }) => { |
| 75 | + await exec('pnpm postcss src/index.css --output dist/out.css') |
| 76 | + |
| 77 | + await fs.expectFileToContain('dist/out.css', [candidate`ui-open:flex`]) |
| 78 | + }, |
| 79 | +) |
0 commit comments