@@ -40,4 +40,357 @@ describe('Challenge Service', function() {
40
40
$httpBackend . flush ( ) ;
41
41
} ) ;
42
42
43
+ it ( 'processPastChallenges should process the won DESIGN/WEB_DESIGNS challenge ' , function ( ) {
44
+ var challenges = [
45
+ {
46
+ id : 30041345 ,
47
+ name : 'Mock Challenge 1' ,
48
+ track : 'DESIGN' ,
49
+ subTrack : 'WEB_DESIGNS' ,
50
+ userDetails : {
51
+ hasUserSubmittedForReview : true ,
52
+ roles : [ 'Submitter' ] ,
53
+ submissions : [
54
+ {
55
+ challengeId : 30041345 ,
56
+ id : 12345 ,
57
+ placement : 1 ,
58
+ score : 98.0 ,
59
+ status : 'Active' ,
60
+ type : 'Contest Submission'
61
+ } ,
62
+ {
63
+ challengeId : 30041345 ,
64
+ id : 12346 ,
65
+ placement : 11 ,
66
+ score : 0.0 ,
67
+ status : 'Failed Review' ,
68
+ type : 'Contest Submission'
69
+ } ,
70
+ {
71
+ challengeId : 30041345 ,
72
+ id : 12347 ,
73
+ placement : 21 ,
74
+ score : 0.0 ,
75
+ status : 'Completed Without Win' ,
76
+ type : 'Checkpoint Submission'
77
+ }
78
+ ]
79
+ }
80
+ }
81
+ ] ;
82
+ ChallengeService . processPastChallenges ( challenges ) ;
83
+ var challenge = challenges [ 0 ] ;
84
+ expect ( challenge . highestPlacement ) . to . exist . to . equal ( 1 ) ;
85
+ expect ( challenge . wonFirst ) . to . exist . to . true ;
86
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'PASSED_REVIEW' ) ;
87
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
88
+ } ) ;
89
+
90
+ it ( 'processPastChallenges should process the won DEVELOP/<ANY> challenge ' , function ( ) {
91
+ var challenges = [
92
+ {
93
+ id : 30041345 ,
94
+ name : 'Mock Challenge 1' ,
95
+ track : 'DEVELOP' ,
96
+ subTrack : 'CODE' ,
97
+ userDetails : {
98
+ hasUserSubmittedForReview : true ,
99
+ roles : [ 'Submitter' ] ,
100
+ submissions : [
101
+ {
102
+ challengeId : 30041345 ,
103
+ id : 12345 ,
104
+ placement : 1 ,
105
+ score : 98.0 ,
106
+ status : 'Active' ,
107
+ type : 'Contest Submission'
108
+ } ,
109
+ {
110
+ challengeId : 30041345 ,
111
+ id : 12346 ,
112
+ placement : 11 ,
113
+ score : 0.0 ,
114
+ status : 'Failed Review' ,
115
+ type : 'Contest Submission'
116
+ } ,
117
+ {
118
+ challengeId : 30041345 ,
119
+ id : 12347 ,
120
+ placement : 21 ,
121
+ score : 0.0 ,
122
+ status : 'Completed Without Win' ,
123
+ type : 'Checkpoint Submission'
124
+ }
125
+ ] ,
126
+ winningPlacements : [ 2 , 11 , 1 ]
127
+ }
128
+
129
+ }
130
+ ] ;
131
+ ChallengeService . processPastChallenges ( challenges ) ;
132
+ var challenge = challenges [ 0 ] ;
133
+ expect ( challenge . highestPlacement ) . to . exist . to . equal ( 1 ) ;
134
+ expect ( challenge . wonFirst ) . to . exist . to . true ;
135
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'PASSED_REVIEW' ) ;
136
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
137
+ } ) ;
138
+
139
+ it ( 'processPastChallenges should process the lost DEVELOP/<ANY> challenge ' , function ( ) {
140
+ var challenges = [
141
+ {
142
+ id : 30041345 ,
143
+ name : 'Mock Challenge 1' ,
144
+ track : 'DEVELOP' ,
145
+ subTrack : 'CODE' ,
146
+ userDetails : {
147
+ hasUserSubmittedForReview : true ,
148
+ roles : [ 'Submitter' ] ,
149
+ submissions : [
150
+ {
151
+ challengeId : 30041345 ,
152
+ id : 12345 ,
153
+ placement : 1 ,
154
+ score : 98.0 ,
155
+ status : 'Active' ,
156
+ type : 'Contest Submission'
157
+ } ,
158
+ {
159
+ challengeId : 30041345 ,
160
+ id : 12346 ,
161
+ placement : 11 ,
162
+ score : 0.0 ,
163
+ status : 'Failed Review' ,
164
+ type : 'Contest Submission'
165
+ } ,
166
+ {
167
+ challengeId : 30041345 ,
168
+ id : 12347 ,
169
+ placement : 21 ,
170
+ score : 0.0 ,
171
+ status : 'Completed Without Win' ,
172
+ type : 'Checkpoint Submission'
173
+ }
174
+ ] ,
175
+ winningPlacements : [ 0 ]
176
+ }
177
+
178
+ }
179
+ ] ;
180
+ ChallengeService . processPastChallenges ( challenges ) ;
181
+ var challenge = challenges [ 0 ] ;
182
+ expect ( challenge . highestPlacement ) . not . to . exist ;
183
+ expect ( challenge . wonFirst ) . to . exist . to . false ;
184
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'PASSED_SCREENING' ) ;
185
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
186
+ } ) ;
187
+
188
+ it ( 'processPastChallenges should process the won DEVELOP/FIRST_2_FINISH challenge ' , function ( ) {
189
+ var challenges = [
190
+ {
191
+ id : 30041345 ,
192
+ name : 'Mock Challenge 1' ,
193
+ track : 'DEVELOP' ,
194
+ subTrack : 'FIRST_2_FINISH' ,
195
+ userDetails : {
196
+ hasUserSubmittedForReview : true ,
197
+ roles : [ 'Submitter' ] ,
198
+ submissions : [
199
+ {
200
+ challengeId : 30041345 ,
201
+ id : 12345 ,
202
+ placement : 1 ,
203
+ score : 98.0 ,
204
+ status : 'Active' ,
205
+ type : 'Contest Submission'
206
+ } ,
207
+ {
208
+ challengeId : 30041345 ,
209
+ id : 12346 ,
210
+ placement : 11 ,
211
+ score : 0.0 ,
212
+ status : 'Failed Review' ,
213
+ type : 'Contest Submission'
214
+ } ,
215
+ {
216
+ challengeId : 30041345 ,
217
+ id : 12347 ,
218
+ placement : 21 ,
219
+ score : 0.0 ,
220
+ status : 'Completed Without Win' ,
221
+ type : 'Checkpoint Submission'
222
+ }
223
+ ]
224
+ }
225
+ }
226
+ ] ;
227
+ ChallengeService . processPastChallenges ( challenges ) ;
228
+ var challenge = challenges [ 0 ] ;
229
+ expect ( challenge . highestPlacement ) . to . exist . to . equal ( 1 ) ;
230
+ expect ( challenge . wonFirst ) . to . exist . to . true ;
231
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'PASSED_REVIEW' ) ;
232
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
233
+ } ) ;
234
+
235
+ it ( 'processPastChallenges should process the lost(without placement) DEVELOP/FIRST_2_FINISH challenge ' , function ( ) {
236
+ var challenges = [
237
+ {
238
+ id : 30041345 ,
239
+ name : 'Mock Challenge 1' ,
240
+ track : 'DEVELOP' ,
241
+ subTrack : 'FIRST_2_FINISH' ,
242
+ userDetails : {
243
+ hasUserSubmittedForReview : true ,
244
+ roles : [ 'Submitter' ] ,
245
+ submissions : [
246
+ {
247
+ challengeId : 30041345 ,
248
+ id : 12345 ,
249
+ placement : null ,
250
+ score : 34.0 ,
251
+ status : 'Active' ,
252
+ type : 'Contest Submission'
253
+ } ,
254
+ {
255
+ challengeId : 30041345 ,
256
+ id : 12346 ,
257
+ placement : null ,
258
+ score : 0.0 ,
259
+ status : 'Failed Review' ,
260
+ type : 'Contest Submission'
261
+ } ,
262
+ {
263
+ challengeId : 30041345 ,
264
+ id : 12347 ,
265
+ placement : 1 ,
266
+ score : 0.0 ,
267
+ status : 'Completed Without Win' ,
268
+ type : 'Checkpoint Submission'
269
+ }
270
+ ]
271
+ }
272
+ }
273
+ ] ;
274
+ ChallengeService . processPastChallenges ( challenges ) ;
275
+ var challenge = challenges [ 0 ] ;
276
+ expect ( challenge . highestPlacement ) . not . to . exist ;
277
+ expect ( challenge . wonFirst ) . to . exist . to . false ;
278
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'PASSED_SCREENING' ) ;
279
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
280
+ } ) ;
281
+
282
+ it ( 'processPastChallenges should process the lost(with placement) DEVELOP/FIRST_2_FINISH challenge ' , function ( ) {
283
+ var challenges = [
284
+ {
285
+ id : 30041345 ,
286
+ name : 'Mock Challenge 1' ,
287
+ track : 'DEVELOP' ,
288
+ subTrack : 'FIRST_2_FINISH' ,
289
+ userDetails : {
290
+ hasUserSubmittedForReview : true ,
291
+ roles : [ 'Submitter' ] ,
292
+ submissions : [
293
+ {
294
+ challengeId : 30041345 ,
295
+ id : 12345 ,
296
+ placement : 5 ,
297
+ score : 34.0 ,
298
+ status : 'Active' ,
299
+ type : 'Contest Submission'
300
+ } ,
301
+ {
302
+ challengeId : 30041345 ,
303
+ id : 12346 ,
304
+ placement : null ,
305
+ score : 0.0 ,
306
+ status : 'Failed Review' ,
307
+ type : 'Contest Submission'
308
+ } ,
309
+ {
310
+ challengeId : 30041345 ,
311
+ id : 12347 ,
312
+ placement : 1 ,
313
+ score : 0.0 ,
314
+ status : 'Completed Without Win' ,
315
+ type : 'Checkpoint Submission'
316
+ }
317
+ ]
318
+ }
319
+ }
320
+ ] ;
321
+ ChallengeService . processPastChallenges ( challenges ) ;
322
+ var challenge = challenges [ 0 ] ;
323
+ expect ( challenge . highestPlacement ) . to . exist . to . equal ( 5 ) ;
324
+ expect ( challenge . wonFirst ) . to . exist . to . false ;
325
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'PASSED_REVIEW' ) ;
326
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
327
+ } ) ;
328
+
329
+ it ( 'processPastChallenges should process a not completed DEVELOP/FIRST_2_FINISH challenge ' , function ( ) {
330
+ var challenges = [
331
+ {
332
+ id : 30041345 ,
333
+ name : 'Mock Challenge 1' ,
334
+ track : 'DEVELOP' ,
335
+ subTrack : 'FIRST_2_FINISH' ,
336
+ userDetails : {
337
+ hasUserSubmittedForReview : false ,
338
+ roles : [ 'Submitter' ] ,
339
+ submissions : [ ]
340
+ }
341
+ }
342
+ ] ;
343
+ ChallengeService . processPastChallenges ( challenges ) ;
344
+ var challenge = challenges [ 0 ] ;
345
+ expect ( challenge . highestPlacement ) . not . to . exist ;
346
+ expect ( challenge . wonFirst ) . to . exist . to . false ;
347
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'NOT_FINISHED' ) ;
348
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . true ;
349
+ } ) ;
350
+
351
+ it ( 'processPastChallenges should process a DEVELOP/FIRST_2_FINISH challenge for a non submitter user ' , function ( ) {
352
+ var challenges = [
353
+ {
354
+ id : 30041345 ,
355
+ name : 'Mock Challenge 1' ,
356
+ track : 'DEVELOP' ,
357
+ subTrack : 'FIRST_2_FINISH' ,
358
+ userDetails : {
359
+ hasUserSubmittedForReview : false ,
360
+ roles : [ 'Observer' ] ,
361
+ submissions : [ ]
362
+ }
363
+ }
364
+ ] ;
365
+ ChallengeService . processPastChallenges ( challenges ) ;
366
+ var challenge = challenges [ 0 ] ;
367
+ expect ( challenge . highestPlacement ) . not . to . exist ;
368
+ expect ( challenge . wonFirst ) . to . exist . to . false ;
369
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'COMPLETED' ) ;
370
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . false ;
371
+ } ) ;
372
+
373
+ it ( 'processPastChallenges should process a DEVELOP/<ANY> challenge for a user without role ' , function ( ) {
374
+ var challenges = [
375
+ {
376
+ id : 30041345 ,
377
+ name : 'Mock Challenge 1' ,
378
+ track : 'DEVELOP' ,
379
+ subTrack : 'FIRST_2_FINISH' ,
380
+ userDetails : {
381
+ hasUserSubmittedForReview : false ,
382
+ roles : [ ] ,
383
+ submissions : [ ] ,
384
+ winningPlacements : [ 0 ]
385
+ }
386
+ }
387
+ ] ;
388
+ ChallengeService . processPastChallenges ( challenges ) ;
389
+ var challenge = challenges [ 0 ] ;
390
+ expect ( challenge . highestPlacement ) . not . to . exist ;
391
+ expect ( challenge . wonFirst ) . to . exist . to . false ;
392
+ expect ( challenge . userStatus ) . to . exist . to . equal ( 'COMPLETED' ) ;
393
+ expect ( challenge . userHasSubmitterRole ) . to . exist . to . false ;
394
+ } ) ;
395
+
43
396
} ) ;
0 commit comments