test: 💍 coverage for session-store

This commit is contained in:
Randall Morey committed 2020-07-31 16:47:15 -04:00
1 parent 1f74aa8bfc
commit 5a6c50d6ae
2 files changed
+1 -21

No files matched your search

+1 -9
View File
@@ -14,7 +14,7 @@ export default class ApplicationSessionStore extends LocalStorageSessionStore {
*/
persist(sessionData) {
this.addTokenToAuthorization(sessionData);
this.addScopeToSession(sessionData);
//this.addScopeToSession(sessionData);
return super.persist(...arguments);
}
@@ -32,14 +32,6 @@ export default class ApplicationSessionStore extends LocalStorageSessionStore {
if (token) adapter.headers.Authorization = `Bearer ${token}`;
}
/**
* @param {object} sessionData
*/
addScopeToSession(sessionData) {
const scope = get(this, 'scope');
const authenticated = get(sessionData, 'authenticated');
if (scope && authenticated) authenticated.scope = scope;
}
}
// import CookieSessionStore from 'auth/session-stores/cookie';
@@ -38,16 +38,4 @@ module('Unit | Session Store | application', function (hooks) {
assert.equal(applicationAdapter.headers.foo, 'bar');
assert.equal(applicationAdapter.headers.Authorization, 'Bearer token1234');
});
test('it adds an org_id to the session data if authenticating within a scope', async function (assert) {
assert.expect(2);
let sessionData = {};
sessionStore.set('scope', {});
sessionStore.persist(sessionData);
assert.notOk(sessionData.authenticated, 'There is no authenticated key');
sessionData = { authenticated: {} };
sessionStore.set('scope', { org: { id: 1 } });
sessionStore.persist(sessionData);
assert.equal(sessionData.authenticated.org_id, 1);
});
});