@@ -5,50 +5,79 @@ import updateStorybookTsconfig from './fix-storybook-tsconfig';
5
5
describe ( 'Fix Storybook TSConfig to avoid VSCode error' , ( ) => {
6
6
let tree : Tree ;
7
7
8
- beforeEach ( async ( ) => {
9
- tree = createTreeWithEmptyWorkspace ( ) ;
10
-
11
- writeJson ( tree , 'workspace.json' , {
12
- projects : {
13
- [ 'home-ui-react' ] : {
14
- projectType : 'library' ,
15
- root : 'libs/home/ui-react' ,
16
- sourceRoot : 'libs/home/ui-react/src' ,
17
- targets : {
18
- storybook : {
19
- builder : '@nrwl/storybook:storybook' ,
20
- options : {
21
- uiFramework : '@storybook/react' ,
22
- port : 4400 ,
23
- config : {
24
- configFolder : 'libs/home/ui-react/.storybook' ,
8
+ describe ( 'when project has valid configuration and targets' , ( ) => {
9
+ beforeEach ( async ( ) => {
10
+ tree = createTreeWithEmptyWorkspace ( ) ;
11
+
12
+ writeJson ( tree , 'workspace.json' , {
13
+ projects : {
14
+ [ 'home-ui-react' ] : {
15
+ projectType : 'library' ,
16
+ root : 'libs/home/ui-react' ,
17
+ sourceRoot : 'libs/home/ui-react/src' ,
18
+ targets : {
19
+ storybook : {
20
+ builder : '@nrwl/storybook:storybook' ,
21
+ options : {
22
+ uiFramework : '@storybook/react' ,
23
+ port : 4400 ,
24
+ config : {
25
+ configFolder : 'libs/home/ui-react/.storybook' ,
26
+ } ,
25
27
} ,
26
28
} ,
27
29
} ,
28
30
} ,
29
31
} ,
30
- } ,
32
+ } ) ;
33
+
34
+ writeJson ( tree , 'libs/home/ui-react/.storybook/tsconfig.json' , {
35
+ extends : '../tsconfig.json' ,
36
+ compilerOptions : {
37
+ emitDecoratorMetadata : true ,
38
+ } ,
39
+ } ) ;
31
40
} ) ;
32
41
33
- writeJson ( tree , 'libs/home/ui-react/.storybook/tsconfig.json' , {
34
- extends : '../tsconfig.json' ,
35
- compilerOptions : {
36
- emitDecoratorMetadata : true ,
37
- } ,
42
+ it ( `should add outDir to the storybook tsconfig to avoid VSCode errors` , async ( ) => {
43
+ await updateStorybookTsconfig ( tree ) ;
44
+
45
+ expect (
46
+ readJson ( tree , 'libs/home/ui-react/.storybook/tsconfig.json' )
47
+ ) . toMatchObject ( {
48
+ extends : '../tsconfig.json' ,
49
+ compilerOptions : {
50
+ emitDecoratorMetadata : true ,
51
+ outDir : '' ,
52
+ } ,
53
+ } ) ;
38
54
} ) ;
39
55
} ) ;
40
56
41
- it ( `should add outDir to the storybook tsconfig to avoid VSCode errors` , async ( ) => {
42
- await updateStorybookTsconfig ( tree ) ;
43
-
44
- expect (
45
- readJson ( tree , 'libs/home/ui-react/.storybook/tsconfig.json' )
46
- ) . toMatchObject ( {
47
- extends : '../tsconfig.json' ,
48
- compilerOptions : {
49
- emitDecoratorMetadata : true ,
50
- outDir : '' ,
51
- } ,
57
+ describe ( 'when project has no targets' , ( ) => {
58
+ beforeEach ( async ( ) => {
59
+ tree = createTreeWithEmptyWorkspace ( ) ;
60
+
61
+ writeJson ( tree , 'workspace.json' , {
62
+ projects : {
63
+ [ 'home-ui-react' ] : {
64
+ projectType : 'library' ,
65
+ root : 'libs/home/ui-react' ,
66
+ sourceRoot : 'libs/home/ui-react/src' ,
67
+ } ,
68
+ } ,
69
+ } ) ;
70
+
71
+ writeJson ( tree , 'libs/home/ui-react/.storybook/tsconfig.json' , {
72
+ extends : '../tsconfig.json' ,
73
+ compilerOptions : {
74
+ emitDecoratorMetadata : true ,
75
+ } ,
76
+ } ) ;
77
+ } ) ;
78
+
79
+ it ( `should not throw errors` , async ( ) => {
80
+ await expect ( updateStorybookTsconfig ( tree ) ) . resolves . not . toThrow ( ) ;
52
81
} ) ;
53
82
} ) ;
54
83
} ) ;
0 commit comments