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

Commit c78db97

Browse files
author
Parth Shah
committed
fixing unit tests
1 parent fb39036 commit c78db97

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/services/helpers.service.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,14 @@
166166
function redirectPostLogin(nextParam) {
167167
// make sure domain is topcoder | dev | qa
168168
nextParam = decodeURIComponent(nextParam);
169-
var re1 = /^(\w+\.)*topcoder(-\w+)*\.com/;
169+
var re1 = /^(https?:\/\/)*(\w+\.)*topcoder(-\w+)*\.com/;
170170
var re2 = /^\/\w+/;
171171

172172
if (re1.test(nextParam)) {
173-
$window.location.href = decodeURIComponent(nextParam);
173+
$window.location.href = nextParam;
174174
} else if (re2.test(nextParam)) {
175175
$location.url(nextParam);
176176
} else {
177-
console.log($state);
178177
$state.go('dashboard');
179178
}
180179
}

app/services/helpers.service.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('Helper Service', function() {
66
href: "/"
77
}
88
};
9+
// sinon.spy(fakeWindow.location, "href");
910
var fakeLocation = {
1011
url: function(param) {
1112
return;
@@ -39,8 +40,8 @@ describe('Helper Service', function() {
3940

4041
describe("redirectPostLogin()", function() {
4142
it("should redirect to the next param", function() {
42-
Helpers.redirectPostLogin(encodeURIComponent("www.topcoder-dev.com"));
43-
expect(fakeWindow.location.href).to.equal("www.topcoder-dev.com");
43+
Helpers.redirectPostLogin(encodeURIComponent("http://www.topcoder-dev.com"));
44+
expect(fakeWindow.location.href).to.equal("http://www.topcoder-dev.com");
4445
});
4546

4647
it("should redirect to the next param", function() {

0 commit comments

Comments
 (0)