@@ -11,63 +11,122 @@ describe('@nx/gradle:init', () => {
11
11
tree . write ( 'settings.gradle' , '' ) ;
12
12
} ) ;
13
13
14
- it ( 'should add the plugin' , async ( ) => {
15
- await initGenerator ( tree , {
16
- skipFormat : true ,
17
- skipPackageJson : false ,
14
+ describe ( 'plugin' , ( ) => {
15
+ it ( 'should add the plugin' , async ( ) => {
16
+ await initGenerator ( tree , {
17
+ skipFormat : true ,
18
+ skipPackageJson : false ,
19
+ } ) ;
20
+ const nxJson = readNxJson ( tree ) ;
21
+ expect ( nxJson . plugins ) . toMatchInlineSnapshot ( `
22
+ [
23
+ {
24
+ "options": {
25
+ "buildTargetName": "build",
26
+ "classesTargetName": "classes",
27
+ "testTargetName": "test",
28
+ },
29
+ "plugin": "@nx/gradle",
30
+ },
31
+ ]
32
+ ` ) ;
18
33
} ) ;
19
- const nxJson = readNxJson ( tree ) ;
20
- expect ( nxJson . plugins ) . toMatchInlineSnapshot ( `
21
- [
22
- {
23
- "options": {
24
- "buildTargetName": "build",
25
- "classesTargetName": "classes",
26
- "testTargetName": "test",
27
- },
28
- "plugin": "@nx/gradle",
29
- },
30
- ]
31
- ` ) ;
32
- } ) ;
33
34
34
- it ( 'should not overwrite existing plugins' , async ( ) => {
35
- updateNxJson ( tree , {
36
- plugins : [ 'foo' ] ,
35
+ it ( 'should not overwrite existing plugins' , async ( ) => {
36
+ updateNxJson ( tree , {
37
+ plugins : [ 'foo' ] ,
38
+ } ) ;
39
+ await initGenerator ( tree , {
40
+ skipFormat : true ,
41
+ skipPackageJson : false ,
42
+ } ) ;
43
+ const nxJson = readNxJson ( tree ) ;
44
+ expect ( nxJson . plugins ) . toMatchInlineSnapshot ( `
45
+ [
46
+ "foo",
47
+ {
48
+ "options": {
49
+ "buildTargetName": "build",
50
+ "classesTargetName": "classes",
51
+ "testTargetName": "test",
52
+ },
53
+ "plugin": "@nx/gradle",
54
+ },
55
+ ]
56
+ ` ) ;
37
57
} ) ;
38
- await initGenerator ( tree , {
39
- skipFormat : true ,
40
- skipPackageJson : false ,
58
+
59
+ it ( 'should not add plugin if already in array' , async ( ) => {
60
+ updateNxJson ( tree , {
61
+ plugins : [ '@nx/gradle' ] ,
62
+ } ) ;
63
+ await initGenerator ( tree , {
64
+ skipFormat : true ,
65
+ skipPackageJson : false ,
66
+ } ) ;
67
+ const nxJson = readNxJson ( tree ) ;
68
+ expect ( nxJson . plugins ) . toMatchInlineSnapshot ( `
69
+ [
70
+ "@nx/gradle",
71
+ ]
72
+ ` ) ;
41
73
} ) ;
42
- const nxJson = readNxJson ( tree ) ;
43
- expect ( nxJson . plugins ) . toMatchInlineSnapshot ( `
44
- [
45
- "foo",
46
- {
47
- "options": {
48
- "buildTargetName": "build",
49
- "classesTargetName": "classes",
50
- "testTargetName": "test",
51
- },
52
- "plugin": "@nx/gradle",
53
- },
54
- ]
55
- ` ) ;
56
74
} ) ;
57
75
58
- it ( 'should not add plugin if already in array' , async ( ) => {
59
- updateNxJson ( tree , {
60
- plugins : [ '@nx/gradle' ] ,
76
+ describe ( 'namedInputs' , ( ) => {
77
+ it ( 'should add the namedInputs' , async ( ) => {
78
+ await initGenerator ( tree , {
79
+ skipFormat : true ,
80
+ skipPackageJson : false ,
81
+ } ) ;
82
+ const nxJson = readNxJson ( tree ) ;
83
+ expect ( nxJson . namedInputs ) . toMatchInlineSnapshot ( `
84
+ {
85
+ "default": [
86
+ "{projectRoot}/**/*",
87
+ ],
88
+ "production": [
89
+ "default",
90
+ "!{projectRoot}/test/**/*",
91
+ ],
92
+ }
93
+ ` ) ;
61
94
} ) ;
62
- await initGenerator ( tree , {
63
- skipFormat : true ,
64
- skipPackageJson : false ,
95
+
96
+ it ( 'should not overwrite existing namedInputs' , async ( ) => {
97
+ updateNxJson ( tree , {
98
+ namedInputs : {
99
+ default : [ 'foo' ] ,
100
+ production : [
101
+ 'bar' ,
102
+ '!{projectRoot}/cypress/**/*' ,
103
+ '!{projectRoot}/**/*.cy.[jt]s?(x)' ,
104
+ '!{projectRoot}/cypress.config.[jt]s' ,
105
+ '!{projectRoot}/test/**/*' ,
106
+ ] ,
107
+ } ,
108
+ } ) ;
109
+ await initGenerator ( tree , {
110
+ skipFormat : true ,
111
+ skipPackageJson : false ,
112
+ } ) ;
113
+ const nxJson = readNxJson ( tree ) ;
114
+ expect ( nxJson . namedInputs ) . toMatchInlineSnapshot ( `
115
+ {
116
+ "default": [
117
+ "foo",
118
+ "{projectRoot}/**/*",
119
+ ],
120
+ "production": [
121
+ "bar",
122
+ "!{projectRoot}/cypress/**/*",
123
+ "!{projectRoot}/**/*.cy.[jt]s?(x)",
124
+ "!{projectRoot}/cypress.config.[jt]s",
125
+ "!{projectRoot}/test/**/*",
126
+ "default",
127
+ ],
128
+ }
129
+ ` ) ;
65
130
} ) ;
66
- const nxJson = readNxJson ( tree ) ;
67
- expect ( nxJson . plugins ) . toMatchInlineSnapshot ( `
68
- [
69
- "@nx/gradle",
70
- ]
71
- ` ) ;
72
131
} ) ;
73
132
} ) ;
0 commit comments