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

Commit b3639fb

Browse files
author
Nick Litwin
committed
Added unit tests for new functionality
1 parent 1cd8025 commit b3639fb

File tree

3 files changed

+60
-10
lines changed

3 files changed

+60
-10
lines changed

app/specs.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ <h1><a href="specs.html">Spec Runner</a></h1>
108108
<script src="/app/topcoder.controller.js"></script>
109109
<script src="/app/topcoder.constants.js"></script>
110110
<script src="/app/submissions/submissions.module.js"></script>
111-
<script src="/app/submissions/submit-file/submit-file.controller.js"></script>
111+
<script src="/app/submissions/submit-design-files/submit-design-files.controller.js"></script>
112112
<script src="/app/submissions/submissions.routes.js"></script>
113113
<script src="/app/submissions/submissions.controller.js"></script>
114114
<script src="/app/skill-picker/skill-picker.module.js"></script>
@@ -288,8 +288,8 @@ <h1><a href="specs.html">Spec Runner</a></h1>
288288
<script src="/app/account/login/login.spec.js"></script>
289289
<script src="/app/account/logout/logout.controller.spec.js"></script>
290290
<script src="/app/account/reset-password/reset-password.spec.js"></script>
291-
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
292291
<script src="/app/account/register/register.spec.js"></script>
292+
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
293293
<script src="/app/directives/badges/badge-tooltip.spec.js"></script>
294294
<script src="/app/directives/busy-button/busy-button.directive.spec.js"></script>
295295
<script src="/app/directives/challenge-tile/challenge-tile.spec.js"></script>
@@ -298,9 +298,9 @@ <h1><a href="specs.html">Spec Runner</a></h1>
298298
<script src="/app/directives/external-account/external-link-deletion.controller.spec.js"></script>
299299
<script src="/app/directives/external-account/external-links-data.directive.spec.js"></script>
300300
<script src="/app/directives/external-account/external-web-links.directive.spec.js"></script>
301+
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.spec.js"></script>
301302
<script src="/app/directives/tc-file-input/tc-file-input.spec.js"></script>
302303
<script src="/app/directives/tc-form-fonts/tc-form-fonts.spec.js"></script>
303-
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.spec.js"></script>
304304
<script src="/app/directives/tc-form-stockart/tc-form-stockart.spec.js"></script>
305305
<script src="/app/directives/tc-input/tc-input.spec.js"></script>
306306
<script src="/app/directives/tc-paginator/tc-paginator.spec.js"></script>
@@ -309,19 +309,19 @@ <h1><a href="specs.html">Spec Runner</a></h1>
309309
<script src="/app/my-dashboard/header-dashboard/header-dashboard.spec.js"></script>
310310
<script src="/app/my-dashboard/my-challenges/my-challenges.spec.js"></script>
311311
<script src="/app/my-dashboard/programs/programs.spec.js"></script>
312-
<script src="/app/my-dashboard/srms/srms.spec.js"></script>
313312
<script src="/app/my-dashboard/subtrack-stats/subtrack-stats.controller.spec.js"></script>
313+
<script src="/app/my-dashboard/srms/srms.spec.js"></script>
314314
<script src="/app/peer-review/completed-review/completed-review.spec.js"></script>
315315
<script src="/app/peer-review/edit-review/edit-review.spec.js"></script>
316316
<script src="/app/peer-review/readOnlyScorecard/readOnlyScorecard.spec.js"></script>
317-
<script src="/app/profile/about/about.controller.spec.js"></script>
318317
<script src="/app/peer-review/review-status/review-status.spec.js"></script>
318+
<script src="/app/profile/about/about.controller.spec.js"></script>
319319
<script src="/app/profile/badges/badges.spec.js"></script>
320320
<script src="/app/profile/subtrack/subtrack.spec.js"></script>
321321
<script src="/app/settings/account-info/account-info.spec.js"></script>
322322
<script src="/app/settings/edit-profile/edit-profile.spec.js"></script>
323323
<script src="/app/settings/preferences/preferences.spec.js"></script>
324-
<script src="/app/submissions/submit-file/submit-file.spec.js"></script>
324+
<script src="/app/submissions/submit-design-files/submit-design-files.spec.js"></script>
325325
<script src="/app/directives/account/toggle-password/toggle-password.spec.js"></script>
326326
<script src="/app/directives/account/toggle-password-with-tips/toggle-password-with-tips.spec.js"></script>
327327
<!-- endinject -->

app/submissions/submissions.spec.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ describe('Submissions Controller', function() {
1010
}
1111
};
1212

13+
var state = {
14+
go: sinon.spy()
15+
}
16+
1317
beforeEach(function() {
1418
bard.appModule('tc.submissions');
1519
bard.inject(this, '$controller');
@@ -19,18 +23,44 @@ describe('Submissions Controller', function() {
1923

2024
beforeEach(function() {
2125
controller = $controller('SubmissionsController', {
22-
challengeToSubmitTo: mockChallenge
26+
challengeToSubmitTo: mockChallenge,
27+
$state: state
2328
});
2429
vm = controller;
2530
});
2631

27-
it('should exist', function() {
32+
it('exists', function() {
2833
expect(vm).to.exist;
2934
});
3035

31-
it('should have properties on vm from the routes resolve', function() {
36+
it('has properties on vm from the routes resolve', function() {
3237
expect(vm.challengeTitle).to.equal(mockChallenge.challenge.name);
3338
expect(vm.challengeId).to.equal(30049240);
3439
expect(vm.track).to.equal(mockChallenge.challenge.track.toLowerCase());
3540
});
41+
42+
describe('routes to the correct child state for', function() {
43+
it('design challenges', function() {
44+
45+
expect(state.go).calledWith('submissions.file.design');
46+
});
47+
48+
it('develop challenges', function() {
49+
50+
controller = $controller('SubmissionsController', {
51+
challengeToSubmitTo: {
52+
challenge: {
53+
name: 'Challenge Name',
54+
track: 'DEVELOP',
55+
id: 30049240
56+
}
57+
},
58+
$state: state
59+
});
60+
vm = controller;
61+
62+
expect(state.go).calledWith('submissions.file.develop');
63+
});
64+
65+
});
3666
});

app/submissions/submit-design-files/submit-design-files.spec.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,30 @@ describe('Submit Design Files Controller', function() {
4848
vm = controller;
4949
});
5050

51-
it('should exist', function() {
51+
it('exists', function() {
5252
expect(vm).to.exist;
5353
});
5454

55+
it('sets the right track for the method', function() {
56+
controller = $controller('SubmitDesignFilesController', {
57+
$scope: scope,
58+
UserService: userService,
59+
challengeToSubmitTo: {
60+
challenge: {
61+
name: 'Challenge Name',
62+
track: 'DEVELOP',
63+
id: 30049240
64+
}
65+
},
66+
SubmissionsService: submissionsService,
67+
$window: mockWindow
68+
});
69+
vm = controller;
70+
scope.$digest();
71+
72+
expect(vm.submissionsBody.data.method).to.equal('DEVELOP_CHALLENGE_ZIP_FILE');
73+
});
74+
5575
describe('setRankTo1', function() {
5676
it('returns 1 if the input is blank', function() {
5777
expect(vm.setRankTo1('')).to.equal(1);

0 commit comments

Comments
 (0)