Skip to content

Commit 187ce12

Browse files
committed
update tests to verify that --types works
1 parent 95b59a5 commit 187ce12

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

+41
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,46 @@ describe('Init command', () => {
319319
// multiple keys in `theme` exists. However it loads `tailwindcss/colors`
320320
// which doesn't exists in this context.
321321
expect((await readOutputFile('../full.config.js')).split('\n').length).toBeGreaterThan(50)
322+
323+
expect(await readOutputFile('../full.config.js')).not.toContain(
324+
`/** @type {import('tailwindcss/types').Config} */`
325+
)
326+
})
327+
328+
test('--types', async () => {
329+
cleanupFile('simple.config.js')
330+
331+
let { combined } = await $(`${EXECUTABLE} init simple.config.js --types`)
332+
333+
expect(combined).toMatchInlineSnapshot(`
334+
"
335+
Created Tailwind CSS config file: simple.config.js
336+
"
337+
`)
338+
339+
expect(await readOutputFile('../simple.config.js')).toContain(
340+
`/** @type {import('tailwindcss/types').Config} */`
341+
)
342+
})
343+
344+
test('--full --types', async () => {
345+
cleanupFile('full.config.js')
346+
347+
let { combined } = await $(`${EXECUTABLE} init full.config.js --full --types`)
348+
349+
expect(combined).toMatchInlineSnapshot(`
350+
"
351+
Created Tailwind CSS config file: full.config.js
352+
"
353+
`)
354+
355+
// Not a clean way to test this. We could require the file and verify that
356+
// multiple keys in `theme` exists. However it loads `tailwindcss/colors`
357+
// which doesn't exists in this context.
358+
expect((await readOutputFile('../full.config.js')).split('\n').length).toBeGreaterThan(50)
359+
expect(await readOutputFile('../full.config.js')).toContain(
360+
`/** @type {import('tailwindcss/types').Config} */`
361+
)
322362
})
323363

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

0 commit comments

Comments
 (0)