Skip to content

Commit

Permalink
add integration tests to validate piping to the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Jan 4, 2022
1 parent b042956 commit 1811b0d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions integrations/tailwindcss-cli/tests/integration.test.js
@@ -1,3 +1,4 @@
let { Readable } = require('stream')
let $ = require('../../execute')
let { css, html, javascript } = require('../../syntax')

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

class ReadableString extends Readable {
constructor(string) {
super()
this.data = string
}

_read() {
this.push(this.data)
this.push(null)
}
}

describe('static build', () => {
it('should be possible to generate tailwind output', async () => {
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
Expand All @@ -27,6 +40,30 @@ describe('static build', () => {
)
})

it('should be possible to pipe in data', async () => {
await writeInputFile('index.html', html`<div class="font-bold"></div>`)

let initialCss = css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`
let customStdin = new ReadableString(initialCss)

await $('node ../../lib/cli.js -o ./dist/main.css', {
stdio: [customStdin, 'pipe', 'pipe'],
env: { NODE_ENV: 'production' },
})

expect(await readOutputFile('main.css')).toIncludeCss(
css`
.font-bold {
font-weight: 700;
}
`
)
})

it('should safelist a list of classes to always include', async () => {
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
await writeInputFile(
Expand Down

0 comments on commit 1811b0d

Please sign in to comment.