diff --git a/src/app/components/analytics/analytics.component.spec.ts b/src/app/components/analytics/analytics.component.spec.ts index 61fe72b5f..402c7c984 100644 --- a/src/app/components/analytics/analytics.component.spec.ts +++ b/src/app/components/analytics/analytics.component.spec.ts @@ -54,11 +54,4 @@ describe('AnalyticsComponent', () => { expect(component).toBeTruthy(); }); - it('should call ngOninit', () => { - component.ngOnInit(); - }); - - it('should call ngOnDestroy', () => { - component.ngOnDestroy(); - }); }); diff --git a/src/app/components/analytics/host-analytics/host-analytics.component.spec.ts b/src/app/components/analytics/host-analytics/host-analytics.component.spec.ts index dfde671bc..d42c398ad 100644 --- a/src/app/components/analytics/host-analytics/host-analytics.component.spec.ts +++ b/src/app/components/analytics/host-analytics/host-analytics.component.spec.ts @@ -120,7 +120,7 @@ describe('HostAnalyticsComponent', () => { expect(service.getUrl).toHaveBeenCalled(); expect(service3.teamCountAnalyticsURL).toHaveBeenCalled(); })); - it('should show download challenge participant team', inject([EndpointsService, ApiService], + it('should download challenge participant team', inject([EndpointsService, ApiService], (service: EndpointsService, service2: ApiService) => { const result = { 'results' : [{'id': '1'}], diff --git a/src/app/components/auth/login/login.component.spec.ts b/src/app/components/auth/login/login.component.spec.ts index e1de98c40..9cbb6d8a4 100644 --- a/src/app/components/auth/login/login.component.spec.ts +++ b/src/app/components/auth/login/login.component.spec.ts @@ -67,7 +67,7 @@ describe('LoginComponent', () => { spyOn(service2, 'postUrl').and.returnValue(new Observable((observation) => { observation.next({'token': [{}]}); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.userLogin(false); @@ -78,7 +78,7 @@ describe('LoginComponent', () => { let err = {}; spyOn(service, 'postUrl').and.returnValue(new Observable((observation) => { observation.error(err); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.userLogin(true); diff --git a/src/app/components/auth/reset-password-confirm/reset-password-confirm.component.spec.ts b/src/app/components/auth/reset-password-confirm/reset-password-confirm.component.spec.ts index ab02433db..b46bccd8a 100644 --- a/src/app/components/auth/reset-password-confirm/reset-password-confirm.component.spec.ts +++ b/src/app/components/auth/reset-password-confirm/reset-password-confirm.component.spec.ts @@ -44,7 +44,7 @@ describe('ResetPasswordConfirmComponent', () => { spyOn(service, 'postUrl').and.returnValue(new Observable((observation) => { observation.next({'data': {'detail': 'detail_goes_here'}}); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.resetPasswordConfirm(false); diff --git a/src/app/components/auth/reset-password/reset-password.component.spec.ts b/src/app/components/auth/reset-password/reset-password.component.spec.ts index fe5f50a1d..468c18613 100644 --- a/src/app/components/auth/reset-password/reset-password.component.spec.ts +++ b/src/app/components/auth/reset-password/reset-password.component.spec.ts @@ -36,7 +36,7 @@ describe('ResetPasswordComponent', () => { spyOn(service, 'postUrl').and.returnValue(new Observable((observation) => { observation.next({'detail': 'testing_detail_goes_here'}); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.resetPassword(false); @@ -47,7 +47,7 @@ describe('ResetPasswordComponent', () => { const error = {}; spyOn(service, 'postUrl').and.returnValue(new Observable((observation) => { observation.error(error); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.resetPassword(true); diff --git a/src/app/components/auth/signup/signup.component.spec.ts b/src/app/components/auth/signup/signup.component.spec.ts index 6f744d306..6af2c388d 100644 --- a/src/app/components/auth/signup/signup.component.spec.ts +++ b/src/app/components/auth/signup/signup.component.spec.ts @@ -46,7 +46,7 @@ describe('SignupComponent', () => { spyOn(service, 'postUrl').and.returnValue(new Observable((observation) => { observation.next({'status': 201}); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.userSignUp(false); @@ -57,7 +57,7 @@ describe('SignupComponent', () => { let err = {}; spyOn(service, 'postUrl').and.returnValue(new Observable((observation) => { observation.error(err); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.userSignUp(true); diff --git a/src/app/components/auth/verify-email/verify-email.component.spec.ts b/src/app/components/auth/verify-email/verify-email.component.spec.ts index f26350d1f..50de2d738 100644 --- a/src/app/components/auth/verify-email/verify-email.component.spec.ts +++ b/src/app/components/auth/verify-email/verify-email.component.spec.ts @@ -36,7 +36,7 @@ describe('VerifyEmailComponent', () => { spyOn(authService, 'verifyEmail').and.returnValue(new Observable((observation) => { observation.next({}); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); expect(component).toBeTruthy(); }); diff --git a/src/app/components/challenge-create/challenge-create.component.spec.ts b/src/app/components/challenge-create/challenge-create.component.spec.ts index e7a2bc61e..3bbc489f9 100644 --- a/src/app/components/challenge-create/challenge-create.component.spec.ts +++ b/src/app/components/challenge-create/challenge-create.component.spec.ts @@ -75,7 +75,7 @@ describe('ChallengecreateComponent', () => { observation.next(result); observation.error(result); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); component.challengeCreate(); diff --git a/src/app/components/publiclists/teamlist/teamlist.component.spec.ts b/src/app/components/publiclists/teamlist/teamlist.component.spec.ts index 572bb114f..911826342 100644 --- a/src/app/components/publiclists/teamlist/teamlist.component.spec.ts +++ b/src/app/components/publiclists/teamlist/teamlist.component.spec.ts @@ -91,7 +91,7 @@ describe('TeamlistComponent', () => { observation.next(data); observation.error(data); observation.complete(); - return{unsubscribe() {}}; + return {unsubscribe() {}}; })); fixture.detectChanges(); }); diff --git a/src/app/services/endpoints.service.spec.ts b/src/app/services/endpoints.service.spec.ts index c0ea1a1ff..fe8c2d8c0 100644 --- a/src/app/services/endpoints.service.spec.ts +++ b/src/app/services/endpoints.service.spec.ts @@ -62,91 +62,127 @@ describe('EndpointsService', () => { expect(endpointsService.allHostTeamsURL()).toBe('hosts/challenge_host_team'); }); it('should return invite member to host team url' , () => { - expect(endpointsService.hostTeamInviteURL(2)).toBe('hosts/challenge_host_teams/2/invite'); + const hostId = 2; + expect(endpointsService.hostTeamInviteURL(hostId)).toBe('hosts/challenge_host_teams/2/invite'); }); it('should return challenge detail url' , () => { - expect(endpointsService.challengeDetailsURL(2)).toBe('challenges/challenge/2/'); + const hostId = 2; + expect(endpointsService.challengeDetailsURL(hostId)).toBe('challenges/challenge/2/'); }); it('should return challenge star url' , () => { - expect(endpointsService.challengeStarsURL(2)).toBe('challenges/2/'); + const hostId = 2; + expect(endpointsService.challengeStarsURL(hostId)).toBe('challenges/2/'); }); it('should return challenge participant teams url' , () => { - expect(endpointsService.challengeParticipantTeamsURL(2)).toBe('participants/participant_teams/challenges/2/user'); + const hostId = 2; + expect(endpointsService.challengeParticipantTeamsURL(hostId)).toBe('participants/participant_teams/challenges/2/user'); }); it('should return participate url' , () => { - expect(endpointsService.challengeParticipateURL(2, 3)).toBe('challenges/challenge/2/participant_team/3'); + const hostId = 2; + const participantId = 3; + expect(endpointsService.challengeParticipateURL(hostId, participantId)).toBe('challenges/challenge/2/participant_team/3'); }); it('should return challenge phase url' , () => { - expect(endpointsService.challengePhaseURL(2)).toBe('challenges/challenge/2/challenge_phase'); + const hostId = 2; + expect(endpointsService.challengePhaseURL(hostId)).toBe('challenges/challenge/2/challenge_phase'); }); it('should return update challenge detail url' , () => { - expect(endpointsService.updateChallengePhaseDetailsURL(2, 3)).toBe('challenges/challenge/2/challenge_phase/3'); + const hostId = 2; + const participantId = 3; + expect(endpointsService.updateChallengePhaseDetailsURL(hostId, participantId)).toBe('challenges/challenge/2/challenge_phase/3'); }); it('should return challenge phase split url' , () => { - expect(endpointsService.challengePhaseSplitURL(2)).toBe('challenges/2/challenge_phase_split'); + const hostId = 2; + expect(endpointsService.challengePhaseSplitURL(hostId)).toBe('challenges/2/challenge_phase_split'); }); it('should return challenge create url' , () => { - expect(endpointsService.challengeCreateURL(2)).toBe('challenges/challenge/challenge_host_team/2/zip_upload/'); + const hostId = 2; + expect(endpointsService.challengeCreateURL(hostId)).toBe('challenges/challenge/challenge_host_team/2/zip_upload/'); }); it('should return challenge leaderboard url' , () => { - expect(endpointsService.challengeLeaderboardURL(3)).toBe('jobs/challenge_phase_split/3/leaderboard/?page_size=1000'); + const participantId = 3; + expect(endpointsService.challengeLeaderboardURL(participantId)).toBe('jobs/challenge_phase_split/3/leaderboard/?page_size=1000'); }); it('should return challenge phase split url' , () => { - expect(endpointsService.particularChallengePhaseSplitUrl(3)).toBe('challenges/challenge/create/challenge_phase_split/3/'); + const participantId = 3; + expect(endpointsService.particularChallengePhaseSplitUrl(participantId)).toBe('challenges/challenge/create/challenge_phase_split/3/'); }); it('should return challenge submission url' , () => { - expect(endpointsService.challengeSubmissionURL(2, 3)).toBe('jobs/challenge/2/challenge_phase/3/submission/'); + const hostId = 2; + const participantId = 3; + expect(endpointsService.challengeSubmissionURL(hostId, participantId)).toBe('jobs/challenge/2/challenge_phase/3/submission/'); }); it('should return challenge submission with filter url' , () => { - expect(endpointsService.challengeSubmissionWithFilterQueryURL(2, 3, 'team_name')) + const hostId = 2; + const participantId = 3; + expect(endpointsService.challengeSubmissionWithFilterQueryURL(hostId, participantId, 'team_name')) .toBe('jobs/challenge/2/challenge_phase/3/submission?participant_team__team_name=team_name'); }); it('should return all challenge submission url' , () => { - expect(endpointsService.allChallengeSubmissionURL(2, 3)).toBe('challenges/2/challenge_phase/3/submissions'); + const hostId = 2; + const participantId = 3; + expect(endpointsService.allChallengeSubmissionURL(hostId, participantId)).toBe('challenges/2/challenge_phase/3/submissions'); }); it('should return challenge submission download url' , () => { - expect(endpointsService.challengeSubmissionDownloadURL(2, 3, 'id')) + const hostId = 2; + const participantId = 3; + expect(endpointsService.challengeSubmissionDownloadURL(hostId, participantId, 'id')) .toBe('challenges/2/phase/3/download_all_submissions/id/'); }); it('should return challenge submission count url' , () => { - expect(endpointsService.challengeSubmissionCountURL(2, 3)) + const hostId = 2; + const participantId = 3; + expect(endpointsService.challengeSubmissionCountURL(hostId, participantId)) .toBe('analytics/challenge/2/challenge_phase/3/count'); }); it('should return challenge submission update url' , () => { - expect(endpointsService.challengeSubmissionUpdateURL(2, 3, 4)) + const hostId = 2; + const participantId = 3; + const submissionId = 4; + expect(endpointsService.challengeSubmissionUpdateURL(hostId, participantId, submissionId)) .toBe('jobs/challenge/2/challenge_phase/3/submission/4'); }); it('should return challenge submission remaining url' , () => { - expect(endpointsService.challengeSubmissionsRemainingURL(2)) + const hostId = 2; + expect(endpointsService.challengeSubmissionsRemainingURL(hostId)) .toBe('jobs/2/remaining_submissions'); }); it('should return challenge edit details url' , () => { - expect(endpointsService.editChallengeDetailsURL('host_team', 2)) + const hostId = 2; + expect(endpointsService.editChallengeDetailsURL('host_team', hostId)) .toBe('challenges/challenge_host_team/host_team/challenge/2'); }); it('should return challenge delete url' , () => { - expect(endpointsService.deleteChallengeURL(2)) + const hostId = 2; + expect(endpointsService.deleteChallengeURL(hostId)) .toBe('challenges/challenge/2/disable'); }); it('should return challenge re-run submission url' , () => { - expect(endpointsService.reRunSubmissionURL(2)) + const hostId = 2; + expect(endpointsService.reRunSubmissionURL(hostId)) .toBe('jobs/submissions/2/re-run/'); }); it('should return team count analytics url' , () => { - expect(endpointsService.teamCountAnalyticsURL(2)) + const hostId = 2; + expect(endpointsService.teamCountAnalyticsURL(hostId)) .toBe('analytics/challenge/2/team/count'); }); it('should return challenge phase analytics url' , () => { - expect(endpointsService.challengePhaseAnalyticsURL(2, 3)) + const hostId = 2; + const participantId = 3; + expect(endpointsService.challengePhaseAnalyticsURL(hostId, participantId)) .toBe('analytics/challenge/2/challenge_phase/3/analytics'); }); it('should return last submission analytics url' , () => { - expect(endpointsService.lastSubmissionAnalyticsURL(2, 3)) + const hostId = 2; + const participantId = 3; + expect(endpointsService.lastSubmissionAnalyticsURL(hostId, participantId)) .toBe('analytics/challenge/2/challenge_phase/3/last_submission_datetime_analysis/'); }); it('should return participants analytics url' , () => { - expect(endpointsService.downloadParticipantsAnalyticsURL(2)) + const hostId = 2; + expect(endpointsService.downloadParticipantsAnalyticsURL(hostId)) .toBe('analytics/challenges/2/download_all_participants/'); }); diff --git a/src/app/services/global.service.spec.ts b/src/app/services/global.service.spec.ts index 170384a68..4fd8418e4 100644 --- a/src/app/services/global.service.spec.ts +++ b/src/app/services/global.service.spec.ts @@ -14,16 +14,22 @@ describe('GlobalService', () => { expect(service).toBeTruthy(); })); it('should update scroll Data', () => { - expect(globalService.scrolledStateChange(true)).toBeUndefined(); + const isScroll = true; + expect(globalService.scrolledStateChange(isScroll)).toBeUndefined(); }); it('should Store Data', () => { - expect(globalService.storeData(6, 1)).toBe(); + const key = 6; + const value = 1; + expect(globalService.storeData(key, value)).toBe(); }); it('should Get Data', () => { - expect(globalService.getData(6)).toBe(1); + const key = 6; + const value = 1; + expect(globalService.getData(key)).toBe(value); }); it('should Delete Data', () => { - expect(globalService.deleteData(6)).toBe(); + const key = 6; + expect(globalService.deleteData(key)).toBe(); }); it('should Reset Store', () => { expect(globalService.resetStorage()).toBe(); @@ -125,9 +131,11 @@ describe('GlobalService', () => { }); it('should Show Integer Validation', () => { - expect(globalService.validateInteger(19)).toBe(true); + const intValue = 19; + const negativeInteger = -19; + expect(globalService.validateInteger(intValue)).toBe(true); - expect(globalService.validateInteger(-19)).toBe(false); + expect(globalService.validateInteger(negativeInteger)).toBe(false); }); it('should Show password Validation', () => { expect(globalService.validatePassword('Password String')).toBe(true);