Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 8c1e917

Browse files
author
vikasrohit
committed
SUP-2895, [Profile/Dashboard] F2F challenges not displaying placement
-- Write unit tests for processPastSRM and processPastMarathonMatch methods -- Fixed bug in processPastSRM method, though the method is not used anywhere as of now
1 parent 76ba1a5 commit 8c1e917

File tree

2 files changed

+121
-2
lines changed

2 files changed

+121
-2
lines changed

app/services/challenge.service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
function processPastSRM(challenge) {
169169
if (Array.isArray(challenge.rounds) && challenge.rounds.length
170170
&& challenge.rounds[0].userSRMDetails) {
171-
challenge.newRating = challenge.rounds[0].userMMDetails.newRating;
172-
challenge.pointTotal = challenge.rounds[0].userMMDetails.pointTotal;
171+
challenge.newRating = challenge.rounds[0].userSRMDetails.newRating;
172+
challenge.finalPoints = challenge.rounds[0].userSRMDetails.finalPoints;
173173
}
174174
}
175175

app/services/challenge.service.spec.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,123 @@ describe('Challenge Service', function() {
393393
expect(challenge.userHasSubmitterRole).to.exist.to.false;
394394
});
395395

396+
it('processPastSRM should process SRM with valid placement ', function() {
397+
var srm = {
398+
id: 4460,
399+
name: "Holder",
400+
status: "PAST",
401+
track: "DATA_SCIENCE",
402+
subTrack : "SRM",
403+
startDate: "8/30/15 12:00 AM",
404+
endDate: "8/30/15 12:00 AM",
405+
rounds: [
406+
{
407+
id: 12345,
408+
forumId: 54321,
409+
status: "PAST",
410+
userSRMDetails: {
411+
newRating: 678,
412+
finalPoints: 226.45
413+
}
414+
}
415+
]
416+
};
417+
ChallengeService.processPastSRM(srm);
418+
expect(srm.newRating).to.exist.to.equal(678);
419+
expect(srm.finalPoints).to.exist.to.equal(226.45);
420+
});
421+
422+
it('processPastSRM should process SRM without rounds gracefully ', function() {
423+
var srm = {
424+
id: 4460,
425+
name: "Holder",
426+
status: "PAST",
427+
track: "DATA_SCIENCE",
428+
subTrack : "SRM",
429+
startDate: "8/30/15 12:00 AM",
430+
endDate: "8/30/15 12:00 AM",
431+
rounds: []
432+
};
433+
ChallengeService.processPastSRM(srm);
434+
expect(srm.newRating).not.to.exist;
435+
expect(srm.finalPoints).not.to.exist;
436+
});
437+
438+
it('processPastMarathonMatch should process MM with valid placement ', function() {
439+
var mm = {
440+
id: 4460,
441+
name: "Holder",
442+
status: "PAST ",
443+
track: "DATA_SCIENCE",
444+
subTrack : "MARATHON_MATCH",
445+
startDate: "8/30/15 12:00 AM",
446+
endDate: "8/30/15 12:00 AM",
447+
rounds: [
448+
{
449+
id: 12345,
450+
forumId: 54321,
451+
status: "PAST",
452+
systemTestEndAt: "8/29/15 12:00 AM",
453+
userMMDetails: {
454+
newRating: 678,
455+
rated: true,
456+
pointTotal: 22645
457+
}
458+
}
459+
]
460+
};
461+
ChallengeService.processPastMarathonMatch(mm);
462+
expect(mm.status).to.exist.to.equal("PAST");// should trim the status
463+
expect(mm.newRating).to.exist.to.equal(678);
464+
expect(mm.pointTotal).to.exist.to.equal(22645);
465+
expect(mm.submissionEndDate).to.exist.to.equal("8/29/15 12:00 AM");
466+
});
467+
468+
it('processPastMarathonMatch should process MM without rounds gracefully ', function() {
469+
var mm = {
470+
id: 4460,
471+
name: "Holder",
472+
status: "PAST",
473+
track: "DATA_SCIENCE",
474+
subTrack : "MARATHON_MATCH",
475+
startDate: "8/30/15 12:00 AM",
476+
endDate: "8/30/15 12:00 AM",
477+
rounds: []
478+
};
479+
ChallengeService.processPastMarathonMatch(mm);
480+
expect(mm.newRating).not.to.exist;
481+
expect(mm.pointTotal).not.to.exist;
482+
expect(mm.submissionEndDate).not.to.exist;
483+
});
484+
485+
it('processPastMarathonMatch should process MM with unrated user details ', function() {
486+
var mm = {
487+
id: 4460,
488+
name: "Holder",
489+
status: "PAST ",
490+
track: "DATA_SCIENCE",
491+
subTrack : "MARATHON_MATCH",
492+
startDate: "8/30/15 12:00 AM",
493+
endDate: "8/30/15 12:00 AM",
494+
rounds: [
495+
{
496+
id: 12345,
497+
forumId: 54321,
498+
status: "PAST",
499+
systemTestEndAt: "8/29/15 12:00 AM",
500+
userMMDetails: {
501+
newRating: null,
502+
rated: false,
503+
pointTotal: null
504+
}
505+
}
506+
]
507+
};
508+
ChallengeService.processPastMarathonMatch(mm);
509+
expect(mm.status).to.exist.to.equal("PAST");// should trim the status
510+
expect(mm.newRating).not.to.exist;
511+
expect(mm.pointTotal).not.to.exist;
512+
expect(mm.submissionEndDate).not.to.exist;
513+
});
514+
396515
});

0 commit comments

Comments
 (0)