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

Commit 3751d9f

Browse files
author
Nick Litwin
committed
Pass tests
1 parent 3bf7007 commit 3751d9f

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

app/services/helpers.service.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@
165165

166166
function redirectPostLogin(nextParam) {
167167
// make sure domain is topcoder | dev | qa
168-
var re1 = /^(\w+\.)*topcoder(-\w+)*\.com/,
169-
re2 = /^\/\w+/;
168+
var re1 = /^(\w+\.)*topcoder(-\w+)*\.com/;
169+
var re2 = /^\/\w+/;
170+
170171
if (re1.test(nextParam)) {
171172
$window.location.href = decodeURIComponent(nextParam);
172173
} else if (re2.test(nextParam)) {

app/services/helpers.service.spec.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
/* jshint -W117, -W030 */
22
describe('Helper Service', function() {
33

4-
var service;
5-
4+
var fakeWindow = {
5+
location: {
6+
href: "/"
7+
}
8+
};
69

710
beforeEach(function() {
8-
bard.appModule('tc.services', bard.fakeStateProvider);
9-
bard.inject(this, '$window', '$location', 'Helpers');
10-
11-
bard.mockService($window, {
12-
location: {
13-
href: "/"
14-
}
11+
bard.appModule('tc.services', function($provide) {
12+
$provide.value('$window', fakeWindow);
1513
});
1614

17-
service = Helpers;
15+
bard.inject(this, 'Helpers');
1816
});
1917

20-
describe("Verify isEmail()", function() {
18+
describe("isEmail()", function() {
2119
it('should should return true for "[email protected]"', function() {
22-
expect(service.isEmail("[email protected]")).to.be(true);
20+
expect(Helpers.isEmail("[email protected]")).to.be.true;
2321
});
2422

2523
it('should should return false for "test123"', function() {
26-
expect(service.isEmail("test123")).to.be(false);
24+
expect(Helpers.isEmail("test123")).to.be.false;
2725
});
2826
});
2927

30-
describe("Verify redirectPostLogin()", function() {
31-
it("should redirect to my-dashboard", function() {
32-
service.redirectPostLogin(encodeURIComponent("http://www.topcoder-dev.com"));
33-
expect($window.location.href).to.equal("http://www.topcoder-dev.com");
28+
describe("redirectPostLogin()", function() {
29+
it("should redirect to the next param", function() {
30+
Helpers.redirectPostLogin(encodeURIComponent("www.topcoder-dev.com"));
31+
expect(fakeWindow.location.href).to.equal("www.topcoder-dev.com");
3432
});
3533
});
36-
3734
});

app/specs.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,11 @@ <h1><a href="specs.html">Spec Runner</a></h1>
156156
<script src="/app/my-dashboard/my-dashboard.spec.js"></script>
157157
<script src="/app/profile/profile.controller.spec.js"></script>
158158
<script src="/app/services/challenge.service.spec.js"></script>
159+
<script src="/app/services/helpers.service.spec.js"></script>
159160
<script src="/app/services/profile.service.spec.js"></script>
160-
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
161161
<script src="/app/account/login/login.spec.js"></script>
162162
<script src="/app/account/register/register.spec.js"></script>
163+
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
163164
<script src="/app/directives/challenge-tiles/challenge-tile.spec.js"></script>
164165
<script src="/app/my-dashboard/community-updates/community-updates.spec.js"></script>
165166
<script src="/app/my-dashboard/my-challenges/my-challenges.spec.js"></script>

0 commit comments

Comments
 (0)