@@ -4,7 +4,7 @@ import { SetupTailwindGeneratorSchema } from './schema';
44import { setupTailwindGenerator } from './setup-tailwind-generator' ;
55
66describe ( 'Setup Tailwind generator' , ( ) => {
7- function setupWithProperFiles ( ) {
7+ function setupWithProperFiles ( tailwindImport = '@import "tailwindcss";' ) {
88 const options : SetupTailwindGeneratorSchema = { } ;
99 const tree = createTreeWithEmptyWorkspace ( ) ;
1010
@@ -16,7 +16,7 @@ describe('Setup Tailwind generator', () => {
1616 color: red;
1717 }
1818
19- @import "tailwindcss";
19+ ${ tailwindImport }
2020 ` ,
2121 ) ;
2222
@@ -26,18 +26,22 @@ describe('Setup Tailwind generator', () => {
2626 } ;
2727 }
2828
29- test ( `
29+ const importVariants = [ '@import "tailwindcss";' , "@import 'tailwindcss';" ] ;
30+
31+ test . each ( importVariants ) (
32+ `
3033 GIVEN no options are passed
31- THEN it should generate "simple" style with primary color "cyan-600", base color "slate" and border-radius 0` , async ( ) => {
32- const { tree, options } = setupWithProperFiles ( ) ;
34+ THEN it should generate "simple" style with primary color "cyan-600", base color "slate" and border-radius 0 (base import: %s)` ,
35+ async ( importVariant ) => {
36+ const { tree, options } = setupWithProperFiles ( importVariant ) ;
3337
34- options . rootCssPath = 'src/global.css' ;
38+ options . rootCssPath = 'src/global.css' ;
3539
36- await setupTailwindGenerator ( tree , options ) ;
40+ await setupTailwindGenerator ( tree , options ) ;
3741
38- const updatedGlobalCssContent = tree . read ( 'src/global.css' , 'utf-8' ) ;
42+ const updatedGlobalCssContent = tree . read ( 'src/global.css' , 'utf-8' ) ;
3943
40- expect ( updatedGlobalCssContent ) . toMatchInlineSnapshot ( `
44+ expect ( updatedGlobalCssContent ) . toMatchInlineSnapshot ( `
4145 "test {
4246 color: red;
4347 }
@@ -217,22 +221,25 @@ describe('Setup Tailwind generator', () => {
217221 }
218222 "
219223 ` ) ;
220- } ) ;
221- test ( `
224+ } ,
225+ ) ;
226+ test . each ( importVariants ) (
227+ `
222228 GIVEN style is "brutalist" and primary color is "red-600" and border-radius is 1
223- THEN it should generate the correct theme` , async ( ) => {
224- const { tree, options } = setupWithProperFiles ( ) ;
229+ THEN it should generate the correct theme (base import: %s)` ,
230+ async ( importVariant ) => {
231+ const { tree, options } = setupWithProperFiles ( importVariant ) ;
225232
226- options . rootCssPath = 'src/global.css' ;
227- options . borderRadius = ThemeBorderRadiuses [ 'BORDER-RADIUS-1' ] ;
228- options . primaryColor = ThemePrimaryColors . RED600 ;
229- options . style = ThemeStyles . BRUTALIST ;
233+ options . rootCssPath = 'src/global.css' ;
234+ options . borderRadius = ThemeBorderRadiuses [ 'BORDER-RADIUS-1' ] ;
235+ options . primaryColor = ThemePrimaryColors . RED600 ;
236+ options . style = ThemeStyles . BRUTALIST ;
230237
231- await setupTailwindGenerator ( tree , options ) ;
238+ await setupTailwindGenerator ( tree , options ) ;
232239
233- const updatedGlobalCssContent = tree . read ( 'src/global.css' , 'utf-8' ) ;
240+ const updatedGlobalCssContent = tree . read ( 'src/global.css' , 'utf-8' ) ;
234241
235- expect ( updatedGlobalCssContent ) . toMatchInlineSnapshot ( `
242+ expect ( updatedGlobalCssContent ) . toMatchInlineSnapshot ( `
236243 "test {
237244 color: red;
238245 }
@@ -406,5 +413,6 @@ describe('Setup Tailwind generator', () => {
406413 }
407414 "
408415 ` ) ;
409- } ) ;
416+ } ,
417+ ) ;
410418} ) ;
0 commit comments