Skip to content

Commit 1811b0d

Browse files
committed
add integration tests to validate piping to the CLI
1 parent b042956 commit 1811b0d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

integrations/tailwindcss-cli/tests/integration.test.js

+37
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
let { Readable } = require('stream')
12
let $ = require('../../execute')
23
let { css, html, javascript } = require('../../syntax')
34

@@ -10,6 +11,18 @@ function ready(message) {
1011
return message.includes('Done in')
1112
}
1213

14+
class ReadableString extends Readable {
15+
constructor(string) {
16+
super()
17+
this.data = string
18+
}
19+
20+
_read() {
21+
this.push(this.data)
22+
this.push(null)
23+
}
24+
}
25+
1326
describe('static build', () => {
1427
it('should be possible to generate tailwind output', async () => {
1528
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
@@ -27,6 +40,30 @@ describe('static build', () => {
2740
)
2841
})
2942

43+
it('should be possible to pipe in data', async () => {
44+
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
45+
46+
let initialCss = css`
47+
@tailwind base;
48+
@tailwind components;
49+
@tailwind utilities;
50+
`
51+
let customStdin = new ReadableString(initialCss)
52+
53+
await $('node ../../lib/cli.js -o ./dist/main.css', {
54+
stdio: [customStdin, 'pipe', 'pipe'],
55+
env: { NODE_ENV: 'production' },
56+
})
57+
58+
expect(await readOutputFile('main.css')).toIncludeCss(
59+
css`
60+
.font-bold {
61+
font-weight: 700;
62+
}
63+
`
64+
)
65+
})
66+
3067
it('should safelist a list of classes to always include', async () => {
3168
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
3269
await writeInputFile(

0 commit comments

Comments
 (0)