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

Commit c820807

Browse files
committed
buncha new tests
1 parent b757d55 commit c820807

File tree

6 files changed

+85
-22
lines changed

6 files changed

+85
-22
lines changed

app/filters/filters.spec.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe('filters', function() {
33

44
beforeEach(function() {
55
bard.appModule('topcoder');
6-
bard.inject(this, 'CONSTANTS', 'roleFilter', 'percentageFilter', 'ordinalFilter', 'displayLocationFilter', 'listRolesFilter', 'trackFilter', 'challengeLinksFilter');
6+
bard.inject(this, 'CONSTANTS', 'roleFilter', 'percentageFilter', 'ordinalFilter', 'displayLocationFilter', 'listRolesFilter', 'trackFilter', 'challengeLinksFilter', 'externalLinkColorFilter', 'emptyFilter', 'iifFilter');
77
domain = CONSTANTS.domain;
88
});
99

@@ -98,4 +98,41 @@ describe('filters', function() {
9898
expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewStandings&rd=3');
9999
});
100100
});
101+
102+
describe('externalLinkColorFilter', function() {
103+
104+
it('should handle twitter and linkedin correctly', function() {
105+
expect(externalLinkColorFilter('el-twitter')).to.be.equal('#62AADC');
106+
expect(externalLinkColorFilter('el-linkedin')).to.be.equal('#127CB5');
107+
});
108+
});
109+
110+
describe('emptyFilter', function() {
111+
it('should handle empty stuff correctly', function() {
112+
var a = emptyFilter(0);
113+
var b = emptyFilter(12);
114+
var c = emptyFilter(false);
115+
var d = emptyFilter(NaN);
116+
var e = emptyFilter('NaN');
117+
var f = emptyFilter('');
118+
var g = emptyFilter('%');
119+
expect(a).to.be.equal(0);
120+
expect(b).to.be.equal(12);
121+
expect(c).to.be.equal('-');
122+
expect(d).to.be.equal('-');
123+
expect(e).to.be.equal('-');
124+
expect(f).to.be.equal('-');
125+
expect(g).to.be.equal('-');
126+
});
127+
});
128+
129+
describe('iifFilter', function() {
130+
it('should function logically', function() {
131+
expect(iifFilter(true, 1, 2)).to.be.equal(1);
132+
expect(iifFilter(false, 1, 2)).to.be.equal(2);
133+
expect(iifFilter(0, 1, 2)).to.be.equal(2);
134+
console.log(jstz.determine().name());
135+
expect(iifFilter(true, 'm', 'n')).to.be.equal('m');
136+
});
137+
});
101138
});

app/services/profile.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
getSubTracks: getSubTracks,
3131
getDivisions: getDivisions,
3232

33-
getUserHandleColor: getUserHandleColor,
33+
getUserHandleColor: getUserHandleColor
3434

3535
};
3636
return service;

app/services/profile.service.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ describe('Profile Service', function() {
6565
var subtracks = service.getSubTracks(mockStats, 'develop');
6666
expect(subtracks.length).to.be.equal(11);
6767
});
68+
69+
it('should return divisions', function() {
70+
var divisions = service.getDivisions(mockStats);
71+
var totalProblemsSuccessful = divisions.division1.total.problemsSuccessful;
72+
var totalProblemsFailed = divisions.division1.total.problemsFailed;
73+
expect(totalProblemsSuccessful).to.be.equal(2);
74+
expect(totalProblemsFailed).to.be.equal(1);
75+
});
76+
77+
it('should return user handle color', function() {
78+
expect(service.getUserHandleColor(mockProfile.maxRating.rating)).to.be.equal('black');
79+
});
80+
81+
6882
});
6983

7084
});

app/settings/account-info/account-info.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
vm.saveAccountInfo = saveAccountInfo;
1212
vm.updateCountry = updateCountry;
1313
vm.submitNewPassword = submitNewPassword;
14+
vm.getAddr = getAddr;
1415

1516
activate();
1617

app/settings/account-info/account-info.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,13 @@ describe('Account Info Controller', function() {
9494
expect(fakeStateGo).to.have.been.calledWith('settings.profile');
9595
});
9696
});
97+
98+
describe('get address', function() {
99+
it('should return a correct address', function() {
100+
vm.homeAddress = {};
101+
expect(vm.getAddr().length).to.be.equal(0);
102+
vm.homeAddress = {streetAddr1: 'a', city: 'b', zip: 21};
103+
expect(vm.getAddr().length).to.be.equal(1);
104+
});
105+
});
97106
});

tests/test-helpers/mock-data.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,37 +1167,39 @@ var mockData = (function() {
11671167
function getMockProfile() {
11681168
return {
11691169
"updatedAt": null,
1170-
"createdAt": '2010-04-25T01:32:21.196+0600',
1170+
"createdAt": null,
11711171
"createdBy": null,
11721172
"updatedBy": null,
11731173
"userId": 10336829,
11741174
"firstName": "Albert",
1175+
"maxRating": {
1176+
"rating": 1616,
1177+
"track": "DEVELOP",
1178+
"subTrack": "DESIGN"
1179+
},
11751180
"lastName": "Wang",
11761181
"quote": "Competing since 2004, albertwang has achieved ratings in multiple data science, architecture, and devleopment challenge tracks. He is most skilled in component design and architecture",
1177-
"description": "Test description",
1182+
"description": null,
11781183
"otherLangName": "NIAL",
11791184
"handle": "albertwang",
11801185
"email": "[email protected]",
1181-
"addresses": [{
1182-
"updatedAt": null,
1183-
"createdAt": null,
1184-
"createdBy": null,
1185-
"updatedBy": null,
1186-
"addressId": 90263,
1187-
"streetAddr1": "123 Main Street",
1188-
"streetAddr2": "address_2",
1189-
"city": "Santa Clause",
1190-
"zip": "47579",
1191-
"stateCode": "IN",
1192-
"type": "HOME"
1193-
}],
1186+
"addresses": [
1187+
{
1188+
"streetAddr1": "123 Main Street",
1189+
"streetAddr2": "address_2",
1190+
"city": "Santa Clause",
1191+
"zip": "47579",
1192+
"stateCode": "IN",
1193+
"addressId": 90263,
1194+
"type": "Home"
1195+
}
1196+
],
11941197
"homeCountryCode": "USA",
1195-
"competitionCountryCode": "SXM",
1196-
"photo": {
1197-
"imageId": 20744540,
1198-
"photoUrl": "https://www.topcoder.com/i/m/albertwang.jpeg"
1199-
},
1198+
"competitionCountryCode": "CHN",
1199+
"photoURL": "https://topcoder-dev-media.s3.amazonaws.com/member/profile/albertwang-1440793843057.jpg",
12001200
"tracks": [
1201+
"DESIGN",
1202+
"DEVELOP",
12011203
"DATA_SCIENCE"
12021204
]
12031205
};

0 commit comments

Comments
 (0)