@@ -84,19 +84,187 @@ describe("validate skeleton", () => {
84
84
const valid = validateSkeleton ( json ) ;
85
85
expect ( valid ) . toBe ( true ) ;
86
86
} ) ;
87
- it . todo ( "should fail if version is invalid" ) ;
88
- it . todo ( "should fail if version is missing" ) ;
89
- it . todo ( "should fail if config is missing" ) ;
90
- it . todo ( "should fail if config testRunner is missing" ) ;
91
- it . todo ( "should fail if config testRunner command is missing" ) ;
92
- it . todo ( "should fail if config testRunner args tap is missing" ) ;
93
- it . todo ( "should fail if repo is missing" ) ;
94
- it . todo ( "should fail if repo uri is missing" ) ;
95
- it . todo ( "should fail if repo uri is invalid" ) ;
96
- it . todo ( "should fail if repo branch is missing" ) ;
97
- it . todo ( "should fial if level is missing id" ) ;
98
- it . todo ( "should fail if level setup is invalid" ) ;
99
- it . todo ( "should fail if step is missing id" ) ;
100
- it . todo ( "should fail if step setup is invalid" ) ;
101
- it . todo ( "should fail if solution setup is invalid" ) ;
87
+ it ( "should fail if version is invalid" , ( ) => {
88
+ const json = { ...validJson , version : "NOT A VERSION" } ;
89
+
90
+ const valid = validateSkeleton ( json ) ;
91
+ expect ( valid ) . toBe ( false ) ;
92
+ } ) ;
93
+ it ( "should fail if version is missing" , ( ) => {
94
+ const json = { ...validJson , version : undefined } ;
95
+
96
+ const valid = validateSkeleton ( json ) ;
97
+ expect ( valid ) . toBe ( false ) ;
98
+ } ) ;
99
+ it ( "should fail if config is missing" , ( ) => {
100
+ const json = { ...validJson , config : undefined } ;
101
+
102
+ const valid = validateSkeleton ( json ) ;
103
+ expect ( valid ) . toBe ( false ) ;
104
+ } ) ;
105
+ it ( "should fail if config testRunner is missing" , ( ) => {
106
+ const json = {
107
+ ...validJson ,
108
+ config : { ...validJson . config , testRunner : undefined } ,
109
+ } ;
110
+
111
+ const valid = validateSkeleton ( json ) ;
112
+ expect ( valid ) . toBe ( false ) ;
113
+ } ) ;
114
+ it ( "should fail if config testRunner command is missing" , ( ) => {
115
+ const json = {
116
+ ...validJson ,
117
+ config : {
118
+ ...validJson . config ,
119
+ testRunner : { ...validJson . config . testRunner , command : undefined } ,
120
+ } ,
121
+ } ;
122
+
123
+ const valid = validateSkeleton ( json ) ;
124
+ expect ( valid ) . toBe ( false ) ;
125
+ } ) ;
126
+ it ( "should fail if config testRunner args tap is missing" , ( ) => {
127
+ const json = {
128
+ ...validJson ,
129
+ config : {
130
+ ...validJson . config ,
131
+ testRunner : {
132
+ ...validJson . config . testRunner ,
133
+ args : { ...validJson . config . testRunner . args , tap : undefined } ,
134
+ } ,
135
+ } ,
136
+ } ;
137
+
138
+ const valid = validateSkeleton ( json ) ;
139
+ expect ( valid ) . toBe ( false ) ;
140
+ } ) ;
141
+ it ( "should fail if repo is missing" , ( ) => {
142
+ const json = {
143
+ ...validJson ,
144
+ config : {
145
+ ...validJson . config ,
146
+ repo : undefined ,
147
+ } ,
148
+ } ;
149
+
150
+ const valid = validateSkeleton ( json ) ;
151
+ expect ( valid ) . toBe ( false ) ;
152
+ } ) ;
153
+ it ( "should fail if repo uri is missing" , ( ) => {
154
+ const json = {
155
+ ...validJson ,
156
+ config : {
157
+ ...validJson . config ,
158
+ repo : { ...validJson . config . repo , uri : undefined } ,
159
+ } ,
160
+ } ;
161
+
162
+ const valid = validateSkeleton ( json ) ;
163
+ expect ( valid ) . toBe ( false ) ;
164
+ } ) ;
165
+ it ( "should fail if repo uri is invalid" , ( ) => {
166
+ const json = {
167
+ ...validJson ,
168
+ config : {
169
+ ...validJson . config ,
170
+ repo : { ...validJson . config . repo , uri : "NOT A VALID URI" } ,
171
+ } ,
172
+ } ;
173
+
174
+ const valid = validateSkeleton ( json ) ;
175
+ expect ( valid ) . toBe ( false ) ;
176
+ } ) ;
177
+ it ( "should fail if repo branch is missing" , ( ) => {
178
+ const json = {
179
+ ...validJson ,
180
+ config : {
181
+ ...validJson . config ,
182
+ repo : { ...validJson . config . repo , branch : undefined } ,
183
+ } ,
184
+ } ;
185
+
186
+ const valid = validateSkeleton ( json ) ;
187
+ expect ( valid ) . toBe ( false ) ;
188
+ } ) ;
189
+ it ( "should fial if level is missing id" , ( ) => {
190
+ const level1 = { ...validJson . levels [ 0 ] , id : undefined } ;
191
+ const json = {
192
+ ...validJson ,
193
+ levels : [ level1 ] ,
194
+ } ;
195
+
196
+ const valid = validateSkeleton ( json ) ;
197
+ expect ( valid ) . toBe ( false ) ;
198
+ } ) ;
199
+ it ( "should fail if level setup is invalid" , ( ) => {
200
+ const level1 = { ...validJson . levels [ 0 ] , setup : { invalidThing : [ ] } } ;
201
+ const json = {
202
+ ...validJson ,
203
+ levels : [ level1 ] ,
204
+ } ;
205
+
206
+ const valid = validateSkeleton ( json ) ;
207
+ expect ( valid ) . toBe ( false ) ;
208
+ } ) ;
209
+ it ( "should fail if step is missing id" , ( ) => {
210
+ const step1 = { ...validJson . levels [ 0 ] . steps [ 0 ] , id : undefined } ;
211
+ const level1 = { ...validJson . levels [ 0 ] , steps : [ step1 ] } ;
212
+ const json = {
213
+ ...validJson ,
214
+ levels : [ level1 ] ,
215
+ } ;
216
+
217
+ const valid = validateSkeleton ( json ) ;
218
+ expect ( valid ) . toBe ( false ) ;
219
+ } ) ;
220
+ it ( "should fail if step setup is missing" , ( ) => {
221
+ const step1 = { ...validJson . levels [ 0 ] . steps [ 0 ] , setup : undefined } ;
222
+ const level1 = { ...validJson . levels [ 0 ] , steps : [ step1 ] } ;
223
+ const json = {
224
+ ...validJson ,
225
+ levels : [ level1 ] ,
226
+ } ;
227
+
228
+ const valid = validateSkeleton ( json ) ;
229
+ expect ( valid ) . toBe ( false ) ;
230
+ } ) ;
231
+ it ( "should fail if step setup is invalid" , ( ) => {
232
+ const step1 = {
233
+ ...validJson . levels [ 0 ] . steps [ 0 ] ,
234
+ setup : { invalidThing : [ ] } ,
235
+ } ;
236
+ const level1 = { ...validJson . levels [ 0 ] , steps : [ step1 ] } ;
237
+ const json = {
238
+ ...validJson ,
239
+ levels : [ level1 ] ,
240
+ } ;
241
+
242
+ const valid = validateSkeleton ( json ) ;
243
+ expect ( valid ) . toBe ( false ) ;
244
+ } ) ;
245
+ it ( "should not fail if step solution is missing" , ( ) => {
246
+ const step1 = { ...validJson . levels [ 0 ] . steps [ 0 ] , solution : undefined } ;
247
+ const level1 = { ...validJson . levels [ 0 ] , steps : [ step1 ] } ;
248
+ const json = {
249
+ ...validJson ,
250
+ levels : [ level1 ] ,
251
+ } ;
252
+
253
+ const valid = validateSkeleton ( json ) ;
254
+ expect ( valid ) . toBe ( true ) ;
255
+ } ) ;
256
+ it ( "should fail if step solution is invalid" , ( ) => {
257
+ const step1 = {
258
+ ...validJson . levels [ 0 ] . steps [ 0 ] ,
259
+ solution : { invalidThing : [ ] } ,
260
+ } ;
261
+ const level1 = { ...validJson . levels [ 0 ] , steps : [ step1 ] } ;
262
+ const json = {
263
+ ...validJson ,
264
+ levels : [ level1 ] ,
265
+ } ;
266
+
267
+ const valid = validateSkeleton ( json ) ;
268
+ expect ( valid ) . toBe ( false ) ;
269
+ } ) ;
102
270
} ) ;
0 commit comments