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

Commit 1d8b854

Browse files
committed
Merge pull request #148 from appirio-tech/qa-tests
Qa tests
2 parents 92a1863 + 0074ab6 commit 1d8b854

File tree

17 files changed

+122
-144
lines changed

17 files changed

+122
-144
lines changed

app/directives/challenge-tiles/challenge-tile.spec.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
describe('Challenge Tile Directive', function() {
33
var scope;
44
var element;
5+
var domain;
56
var challenge = mockData.getMockChallengeWithUserDetails();
67
var spotlightChallenge = mockData.getMockSpotlightChallenges()[0];
78

89
beforeEach(function() {
910
bard.appModule('topcoder');
10-
bard.inject(this, '$compile', '$rootScope');
11+
bard.inject(this, '$compile', '$rootScope', 'CONSTANTS');
12+
1113
scope = $rootScope.$new();
14+
domain = CONSTANTS.domain;
1215
});
1316

1417
bard.verifyNoOutstandingHttpRequests();
@@ -34,7 +37,7 @@ describe('Challenge Tile Directive', function() {
3437
});
3538

3639
it('should have domain added to the scope', function() {
37-
expect(element.isolateScope().DOMAIN).to.equal('topcoder-dev.com');
40+
expect(element.isolateScope().DOMAIN).to.equal(domain);
3841
});
3942
});
4043

app/my-challenges/my-challenges.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* jshint -W117, -W030 */
22
describe('My Challenges Controller', function() {
33
var controller;
4+
var domain;
45
var authService, challengeService, userService;
56
var marathons = mockData.getMockMarathons();
67
var challenges = mockData.getMockiOSChallenges();
@@ -22,6 +23,7 @@ describe('My Challenges Controller', function() {
2223
getToken: function() { return "v3Token"; }
2324
});
2425

26+
domain = CONSTANTS.domain;
2527
challengeService = ChallengeService;
2628
authService = TcAuthService;
2729
userService = UserService;
@@ -66,9 +68,8 @@ describe('My Challenges Controller', function() {
6668
$rootScope.$apply();
6769
});
6870

69-
it('vm.domain should be initialized to default value', function() {
70-
// default value for domain
71-
expect(myChallenges.domain).to.equal('topcoder-dev.com');
71+
it('vm.domain should exist', function() {
72+
expect(myChallenges.domain).to.equal(domain);
7273
});
7374

7475
it('vm.userHasChallenges should be initialized to default value', function() {

app/my-dashboard/header-dashboard/header-dashboard.spec.js

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* jshint -W117, -W030 */
22
describe('Header Dashboard Controller', function() {
33
var controller;
4+
var domain;
45
var authService, notificationService, userService, profileService;
56
var profile = mockData.getMockProfile();
67
var stats = mockData.getMockStats();
@@ -19,6 +20,7 @@ describe('Header Dashboard Controller', function() {
1920
'CONSTANTS',
2021
'Helpers');
2122

23+
domain = CONSTANTS.domain;
2224
notificationService = NotificationService;
2325
authService = TcAuthService;
2426
userService = UserService;
@@ -78,22 +80,15 @@ describe('Header Dashboard Controller', function() {
7880
});
7981

8082
it('variables should be initialized to correct value', function() {
81-
// default value for domain
82-
expect(controller.domain).to.equal('topcoder-dev.com');
83-
// default value for isCopilot
83+
expect(controller.domain).to.equal(domain);
8484
expect(controller.isCopilot).to.equal(false);
85-
// default value for hasRatings
8685
expect(controller.hasRatings).to.equal(true);
87-
// default value for loading
8886
expect(controller.loading).to.equal(false);
89-
// default value for profile
9087
expect(controller.profile).to.exist;
9188
expect(controller.profile.handle).to.equal('albertwang');
92-
// value for rankStats
9389
expect(controller.rankStats).to.exist;
9490
// there are 7 sub tracks with non null/zero value for one of rank/wins/fulfillment
9591
expect(controller.rankStats).to.have.length(7);
96-
// default value for moneyEarned
9792
expect(controller.moneyEarned).to.equal(5100);
9893
});
9994
});
@@ -117,21 +112,14 @@ describe('Header Dashboard Controller', function() {
117112
});
118113

119114
it('variables should be initialized to correct value', function() {
120-
// default value for domain
121-
expect(controller.domain).to.equal('topcoder-dev.com');
122-
// default value for isCopilot
115+
expect(controller.domain).to.equal(domain);
123116
expect(controller.isCopilot).to.equal(false);
124-
// default value for hasRatings
125117
expect(controller.hasRatings).to.equal(false);
126-
// default value for loading
127118
expect(controller.loading).to.equal(false);
128-
// default value for profile
129119
expect(controller.profile).to.exist;
130120
expect(controller.profile.handle).to.equal('albertwang');
131-
// rankStats should be empty
132121
expect(controller.rankStats).to.exist;
133122
expect(controller.rankStats).to.have.length(0);
134-
// default value for moneyEarned
135123
expect(controller.moneyEarned).to.equal(5100);
136124
});
137125
});
@@ -155,21 +143,14 @@ describe('Header Dashboard Controller', function() {
155143
});
156144

157145
it('variables should be initialized to correct value', function() {
158-
// default value for domain
159-
expect(controller.domain).to.equal('topcoder-dev.com');
160-
// default value for isCopilot
146+
expect(controller.domain).to.equal(domain);
161147
expect(controller.isCopilot).to.equal(false);
162-
// default value for loading
163148
expect(controller.loading).to.equal(false);
164-
// default value for profile
165149
expect(controller.profile).not.to.exist;
166-
// value for rankStats
167150
expect(controller.rankStats).to.exist;
168151
// there are 7 sub tracks with non null/zero value for one of rank/wins/fulfillment
169152
expect(controller.rankStats).to.have.length(7);
170-
// default value for hasRatings
171153
expect(controller.hasRatings).to.equal(true);
172-
// default value for moneyEarned
173154
expect(controller.moneyEarned).to.equal(5100);
174155
});
175156
});
@@ -193,22 +174,15 @@ describe('Header Dashboard Controller', function() {
193174
});
194175

195176
it('variables should be initialized to correct value', function() {
196-
// default value for domain
197-
expect(controller.domain).to.equal('topcoder-dev.com');
198-
// default value for isCopilot
177+
expect(controller.domain).to.equal(domain);
199178
expect(controller.isCopilot).to.equal(false);
200-
// default value for loading
201179
expect(controller.loading).to.equal(false);
202-
// default value for profile
203180
expect(controller.profile).to.exist;
204181
expect(controller.profile.handle).to.equal('albertwang');
205-
// value for rankStats
206182
expect(controller.rankStats).to.exist;
207183
// there are 7 sub tracks with non null/zero value for one of rank/wins/fulfillment
208184
expect(controller.rankStats).to.have.length(7);
209-
// default value for hasRatings
210185
expect(controller.hasRatings).to.equal(true);
211-
// moneyEarned should not exist
212186
expect(controller.moneyEarned).not.to.exist;
213187
});
214188
});

app/my-dashboard/my-challenges/my-challenges.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* jshint -W117, -W030 */
22
describe('Challenges Widget Controller', function() {
33
var controller;
4+
var domain;
45
var authService, challengeService, userService;
56
var marathons = mockData.getMockMarathons();
67
var challenges = mockData.getMockiOSChallenges();
@@ -17,6 +18,7 @@ describe('Challenges Widget Controller', function() {
1718
'CONSTANTS',
1819
'Helpers');
1920

21+
domain = CONSTANTS.domain;
2022
challengeService = ChallengeService;
2123
authService = TcAuthService;
2224
userService = UserService;
@@ -64,7 +66,7 @@ describe('Challenges Widget Controller', function() {
6466

6567
it('vm.domain should be initialized to default value', function() {
6668
// default value for domain
67-
expect(myChallenges.domain).to.equal('topcoder-dev.com');
69+
expect(myChallenges.domain).to.equal(domain);
6870
});
6971

7072
it('vm.userHasChallenges should be initialized to default value', function() {

app/my-dashboard/programs/programs.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* jshint -W117, -W030 */
22
describe('Programs Controller', function() {
33
var controller;
4+
var domain;
45
var authService, challengeService, userService, memberCertService;
56
var marathons = mockData.getMockMarathons();
67
var challenges = mockData.getMockiOSChallenges();
@@ -18,6 +19,7 @@ describe('Programs Controller', function() {
1819
'CONSTANTS',
1920
'Helpers');
2021

22+
domain = CONSTANTS.domain;
2123
challengeService = ChallengeService;
2224
authService = TcAuthService;
2325
userService = UserService;
@@ -70,7 +72,7 @@ describe('Programs Controller', function() {
7072

7173
it('variables initialized to correct value', function() {
7274
// default value for domain
73-
expect(controller.domain).to.equal('topcoder-dev.com');
75+
expect(controller.domain).to.equal(domain);
7476
// default value for registered
7577
expect(controller.registered).to.equal(true);
7678
// default value for loading
@@ -102,7 +104,7 @@ describe('Programs Controller', function() {
102104

103105
it('variables initialized to correct value', function() {
104106
// default value for domain
105-
expect(controller.domain).to.equal('topcoder-dev.com');
107+
expect(controller.domain).to.equal(domain);
106108
// default value for registered
107109
expect(controller.registered).to.equal(false);
108110
// default value for loading
@@ -134,7 +136,7 @@ describe('Programs Controller', function() {
134136

135137
it('variables should be initialized to correct value', function() {
136138
// default value for domain
137-
expect(controller.domain).to.equal('topcoder-dev.com');
139+
expect(controller.domain).to.equal(domain);
138140
// default value for registered
139141
expect(controller.registered).to.equal(false);
140142
// default value for loading

app/peer-review/review-status/review-status.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,4 @@ describe('Review Status Controller', function() {
7979
expect(controller.reviewsDue).to.equal('2015-05-01T04:00Z');
8080
});
8181
});
82-
8382
});

app/profile/profile.controller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
angular.module('tc.profile').controller('ProfileCtrl', ProfileCtrl);
55

6-
ProfileCtrl.$inject = ['$scope', 'CONSTANTS', '$log',
6+
ProfileCtrl.$inject = ['CONSTANTS', '$log',
77
'TcAuthService', 'UserService', 'ProfileService', 'ChallengeService',
88
'userHandle', 'profile', 'ngDialog'
99
];
1010

11-
function ProfileCtrl($scope, CONSTANTS, $log, TcAuthService, UserService, ProfileService, ChallengeService, userHandle, profile, ngDialog) {
11+
function ProfileCtrl(CONSTANTS, $log, TcAuthService, UserService, ProfileService, ChallengeService, userHandle, profile, ngDialog) {
1212
var vm = this;
1313
// set profile to the object that was resolved
1414
vm.profile = profile;
@@ -30,8 +30,8 @@
3030
vm.statsPromise = ProfileService.getUserStats(vm.userHandle).then(function(stats) {
3131
vm.stats = stats;
3232
vm.profile.tracks = vm.profile.tracks || ProfileService.getTracks(vm.stats) || [];
33-
vm.numProjects = ProfileService.getNumProjects(vm.stats);
34-
vm.numWins = ProfileService.getNumWins(vm.stats);
33+
vm.numProjects = vm.stats.challenges;
34+
vm.numWins = vm.stats.wins;
3535
vm.categories = ProfileService.getRanks(vm.stats);
3636
vm.status.stats = CONSTANTS.STATE_READY;
3737
return vm.stats;
Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,58 @@
11
/* jshint -W117, -W030 */
22
describe('Profile Controller', function() {
33
var controller;
4+
var apiUrl;
45
var mockProfile = mockData.getMockProfile();
56
var mockStats = mockData.getMockStats();
67
var mockSkills = mockData.getMockSkills();
7-
var apiUrl = 'https://api.topcoder-dev.com/v3';
88

99
beforeEach(function() {
10-
bard.appModule('topcoder');
1110
bard.appModule('tc.profile');
12-
bard.inject(this, '$httpBackend', '$controller', 'CONSTANTS');
11+
bard.inject(this, '$controller', 'CONSTANTS', '$rootScope', '$q', 'ProfileService');
12+
13+
apiUrl = CONSTANTS.API_URL;
14+
15+
var profileService = {
16+
getUserStats: function() {
17+
return $q.when({result: {content: mockStats}});
18+
},
19+
getUserSkills: function() {
20+
return $q.when({result: {content: mockSkills}});
21+
},
22+
getRanks: ProfileService.getRanks
23+
};
1324

1425
controller = $controller('ProfileCtrl', {
15-
$scope: {},
1626
userHandle: 'rakesh',
17-
profile: mockProfile
27+
profile: mockProfile,
28+
ProfileService: profileService
1829
});
19-
20-
21-
// mock challenges
22-
$httpBackend
23-
.when('GET', new RegExp(apiUrl + '/members.*/challenges/.*'))
24-
.respond(200, {result: {content: []}});
25-
// mock stats
26-
$httpBackend
27-
.when('GET', apiUrl + '/members/rakesh/stats/')
28-
.respond(200, {result: {content: mockStats}});
29-
// mock skills
30-
$httpBackend
31-
.when('GET', apiUrl + '/members/rakesh/skills/')
32-
.respond(200, {result: {content: mockSkills}});
3330
});
3431

35-
afterEach(function() {
36-
$httpBackend.flush();
37-
$httpBackend.verifyNoOutstandingExpectation();
38-
$httpBackend.verifyNoOutstandingRequest();
39-
});
32+
bard.verifyNoOutstandingHttpRequests();
4033

4134
it('should be defined', function() {
4235
expect(controller).to.be.defined;
4336
});
4437

45-
it('should have some properties', function() {
46-
expect(controller.userHandle).to.be.equal('rakesh');
47-
expect(controller.status).to.be.defined;
48-
expect(controller.statsPromise).to.be.defined;
49-
expect(controller.skillsPromise).to.be.defined;
50-
});
38+
describe('after activation', function() {
39+
beforeEach(function() {
40+
$rootScope.$apply();
41+
});
5142

52-
it('should have tenure', function() {
53-
expect(controller.tenure).to.be.equal(5);
54-
});
43+
it('should have some properties', function() {
44+
expect(controller.userHandle).to.be.equal('rakesh');
45+
expect(controller.status).to.be.defined;
46+
expect(controller.statsPromise).to.be.defined;
47+
expect(controller.skillsPromise).to.be.defined;
48+
});
5549

56-
it('should have default status', function() {
57-
expect(controller.status.externalLinks).to.be.equal(CONSTANTS.STATE_READY);
58-
});
50+
it('should have tenure', function() {
51+
expect(controller.tenure).to.equal(5);
52+
});
5953

54+
it('should have default status', function() {
55+
expect(controller.status.externalLinks).to.equal(CONSTANTS.STATE_READY);
56+
});
57+
});
6058
});

app/profile/profile.module.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
'tc.services',
99
'tcUIComponents',
1010
'ngDropdowns',
11-
'angularSlideables'
11+
'angularSlideables',
12+
'ngDialog'
1213
];
1314

1415
angular.module('tc.profile', dependencies);

app/profile/subtrack/subtrack.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('SubTrack Controller', function() {
66
var mockStats = mockData.getMockStats();
77
var mockSkills = mockData.getMockSkills();
88
var mockChallenges = mockData.getMockiOSChallenges();
9-
var apiUrl = 'https://api.topcoder-dev.com/v3';
9+
var apiUrl;
1010
var track = 'develop', subTrack = 'development';
1111
var profileScope, scope;
1212

@@ -24,6 +24,7 @@ describe('SubTrack Controller', function() {
2424
'ProfileService'
2525
);
2626

27+
apiUrl = CONSTANTS.API_URL;
2728
challengeService = ChallengeService;
2829
profileService = ProfileService;
2930

0 commit comments

Comments
 (0)