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

Commit ce8bedf

Browse files
committed
fixed broken tests
1 parent 49e4ad5 commit ce8bedf

File tree

5 files changed

+84
-8
lines changed

5 files changed

+84
-8
lines changed

app/profile/subtrack/subtrack.controller.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
var historyDeferred = $q.defer();
4444
vm.historyPromise = historyDeferred.promise;
4545
ProfileService.getHistoryStats(profileVm.profile.handle).then(function(data) {
46-
vm.history = ProfileService.getChallengeTypeStats(data, vm.track, vm.subTrack).history;
47-
historyDeferred.resolve(vm.history);
46+
if (data.handle) {
47+
vm.history = ProfileService.getChallengeTypeStats(data, vm.track, vm.subTrack).history;
48+
historyDeferred.resolve(vm.history);
49+
}
4850
});
4951
profileVm.statsPromise.then(function(data) {
5052
vm.typeStats = ProfileService.getChallengeTypeStats(

app/profile/subtrack/subtrack.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('SubTrack Controller', function() {
66
var mockStats = mockData.getMockStats();
77
var mockSkills = mockData.getMockSkills();
88
var mockChallenges = mockData.getMockiOSChallenges();
9+
var mockHistory = mockData.getMockHistory();
910
var apiUrl;
1011
var track = 'develop', subTrack = 'development';
1112
var profileScope, scope;
@@ -57,6 +58,10 @@ describe('SubTrack Controller', function() {
5758
.when('GET', apiUrl + '/members/rakesh/stats/')
5859
.respond(200, {result: {content: mockStats}});
5960
// mock skills
61+
$httpBackend
62+
.when('GET', apiUrl + '/members/albertwang/stats/history/')
63+
.respond(200, mockHistory);
64+
// mock history
6065
$httpBackend
6166
.when('GET', apiUrl + '/members/rakesh/skills/')
6267
.respond(200, {result: {content: mockSkills}});
@@ -67,6 +72,13 @@ describe('SubTrack Controller', function() {
6772
deferred.resolve(resp);
6873
return deferred.promise;
6974
});
75+
76+
sinon.stub(profileService, 'getHistoryStats', function(handle) {
77+
var deferred = $q.defer();
78+
var resp = {};
79+
deferred.resolve(resp);
80+
return deferred.promise;
81+
});
7082
});
7183

7284
afterEach(function() {

app/settings/update-password/update-password.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ describe('Update Password Controller', function() {
1212
};
1313

1414
vm = $controller('UpdatePasswordController', {
15+
userData: {
16+
handle: 'foo',
17+
email: 'bar'
18+
},
1519
UserService: {
1620
getUserIdentity: function() {
1721
return {

app/skill-picker/skill-picker.spec.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ describe('Skill Picker Controller', function() {
33
var vm;
44

55
beforeEach(function() {
6-
bard.appModule('tc.settings');
6+
bard.appModule('tc.skill-picker');
77
bard.inject(this, '$controller', '$rootScope', '$q');
88

99
vm = $controller('SkillPickerController', {
10-
userData: userData
1110
});
1211
});
1312

@@ -17,8 +16,4 @@ describe('Skill Picker Controller', function() {
1716
expect(vm).to.exist;
1817
});
1918

20-
describe('user data', function() {
21-
22-
});
23-
2419
});

tests/test-helpers/mock-data.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var mockData = (function() {
1414
getMockUserProfile: getMockUserProfile,
1515
getMockMarathons: getMockMarathons,
1616
getMockProfile: getMockProfile,
17+
getMockHistory: getMockHistory,
1718
getMockStats: getMockStats,
1819
getMockSkills: getMockSkills,
1920
getMockSRMs: getMockSRMs,
@@ -1291,6 +1292,68 @@ var mockData = (function() {
12911292
};
12921293
}
12931294

1295+
function getMockHistory() {
1296+
return {
1297+
"id": "-306aafb8:14f65e30765:-8000",
1298+
"result": {
1299+
"success": true,
1300+
"status": 200,
1301+
"metadata": null,
1302+
"content": {
1303+
"updatedAt": null,
1304+
"createdAt": null,
1305+
"createdBy": null,
1306+
"updatedBy": null,
1307+
"userId": 151743,
1308+
"handle": "Ghostar",
1309+
"DEVELOP": {
1310+
"subTracks": [
1311+
{
1312+
"id": 112,
1313+
"name": "DESIGN",
1314+
"history": [
1315+
{
1316+
"challengeId": 30009817,
1317+
"challengeName": "Disney Marine Munch - Flash Game Module Architecture",
1318+
"ratingDate": "2010-02-28T13:00:00.000Z",
1319+
"newRating": 1172
1320+
}
1321+
]
1322+
},
1323+
{
1324+
"id": 125,
1325+
"name": "ASSEMBLY_COMPETITION",
1326+
"history": [
1327+
{
1328+
"challengeId": 30007872,
1329+
"challengeName": "Best Buy Blackberry Web Application Wrapper Assembly",
1330+
"ratingDate": "2009-10-18T23:30:00.000Z",
1331+
"newRating": 1515
1332+
},
1333+
{
1334+
"challengeId": 30008010,
1335+
"challengeName": "Best Buy Android Web Application Wrapper Assembly",
1336+
"ratingDate": "2009-10-24T01:00:00.000Z",
1337+
"newRating": 1566
1338+
}
1339+
]
1340+
}
1341+
]
1342+
},
1343+
"DATA_SCIENCE": {
1344+
"SRM": {
1345+
"history": []
1346+
},
1347+
"MARATHON_MATCH": {
1348+
"history": []
1349+
}
1350+
}
1351+
}
1352+
},
1353+
"version": "v3"
1354+
}
1355+
}
1356+
12941357
function getMockStats() {
12951358
return {
12961359
"updatedAt": null,

0 commit comments

Comments
 (0)