Skip to content

Commit

Permalink
update tests to verify that --types works
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Mar 21, 2022
1 parent cfd3b9c commit 9796edb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions integrations/tailwindcss-cli/tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,46 @@ describe('Init command', () => {
// multiple keys in `theme` exists. However it loads `tailwindcss/colors`
// which doesn't exists in this context.
expect((await readOutputFile('../full.config.js')).split('\n').length).toBeGreaterThan(50)

expect(await readOutputFile('../full.config.js')).not.toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
})

test('--types', async () => {
cleanupFile('simple.config.js')

let { combined } = await $(`${EXECUTABLE} init simple.config.js --types`)

expect(combined).toMatchInlineSnapshot(`
"
Created Tailwind CSS config file: simple.config.js
"
`)

expect(await readOutputFile('../simple.config.js')).toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
})

test('--full --types', async () => {
cleanupFile('full.config.js')

let { combined } = await $(`${EXECUTABLE} init full.config.js --full --types`)

expect(combined).toMatchInlineSnapshot(`
"
Created Tailwind CSS config file: full.config.js
"
`)

// Not a clean way to test this. We could require the file and verify that
// multiple keys in `theme` exists. However it loads `tailwindcss/colors`
// which doesn't exists in this context.
expect((await readOutputFile('../full.config.js')).split('\n').length).toBeGreaterThan(50)
expect(await readOutputFile('../full.config.js')).toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
})

test('--postcss', async () => {
Expand Down Expand Up @@ -351,6 +391,7 @@ describe('Init command', () => {
Options:
-f, --full Initialize a full \`tailwind.config.js\` file
-p, --postcss Initialize a \`postcss.config.js\` file
--types Add TypeScript types for the \`tailwind.config.js\` file
-h, --help Display usage information
`)
)
Expand Down

0 comments on commit 9796edb

Please sign in to comment.