Skip to content

Commit

Permalink
Added assertion to test the domain is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Aug 14, 2015
1 parent 3d3bff8 commit f76105d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/test.ts
Expand Up @@ -82,10 +82,20 @@ let cookiesFactoryMock = (allowDomain) => {
return false;
}

cookieStore[key] = value;
cookieStore[key] = {
value: value,
conf: conf
};
},

get: (key) => {
if (!cookieStore[key]){
return undefined;
}
return cookieStore[key].value;
},

getObject: (key) => {
return cookieStore[key];
},

Expand Down Expand Up @@ -204,17 +214,19 @@ describe('Service tests', () => {

window.localStorage.clear();

let cookieDomain = 'example.com';
let hostDomain = 'sub.example.com';

beforeEach(()=>{

module(function ($provide) {

$provide.factory('$cookies', cookiesFactoryMock('example.com'));
$provide.factory('$cookies', cookiesFactoryMock(cookieDomain));

$provide.factory('$location', locationFactoryMock('sub.example.com'));
$provide.factory('$location', locationFactoryMock(hostDomain));

});


angular.module('ngCookies',[]); //register the module as being overriden

module('ngJwtAuth');
Expand Down Expand Up @@ -794,7 +806,10 @@ describe('Service tests', () => {

let cookie = $cookies.get(config.cookie.name);

let cookieObject = $cookies.getObject(config.cookie.name);

expect(cookie).to.equal(token);
expect(cookieObject.conf.domain).to.equal(cookieDomain);

});

Expand Down

0 comments on commit f76105d

Please sign in to comment.