mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Fix logged in selector with test
This commit is contained in:
parent
64fecf28bb
commit
c789a27018
2 changed files with 4 additions and 2 deletions
|
@ -121,7 +121,7 @@ module.exports.refreshSessionWithRetry = () => (dispatch => {
|
|||
});
|
||||
|
||||
// Selectors
|
||||
module.exports.selectIsLoggedIn = state => get(state, ['session', 'session', 'user'], false);
|
||||
module.exports.selectIsLoggedIn = state => !!get(state, ['session', 'session', 'user'], false);
|
||||
module.exports.selectUsername = state => get(state, ['session', 'session', 'user', 'username'], null);
|
||||
module.exports.selectToken = state => get(state, ['session', 'session', 'user', 'token'], null);
|
||||
module.exports.selectIsAdmin = state => get(state, ['session', 'session', 'permissions', 'admin'], false);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
getInitialState, selectIsAdmin, selectIsSocial, selectUserId,
|
||||
selectUsername, selectToken, sessionReducer, setSession
|
||||
selectIsLoggedIn, selectUsername, selectToken, sessionReducer, setSession
|
||||
} from '../../../src/redux/session';
|
||||
|
||||
import {sessions} from '../../helpers/state-fixtures.json';
|
||||
|
@ -10,6 +10,7 @@ describe('session selectors', () => {
|
|||
const state = {session: getInitialState()};
|
||||
expect(selectIsAdmin(state)).toBe(false);
|
||||
expect(selectIsSocial(state)).toBe(false);
|
||||
expect(selectIsLoggedIn(state)).toBe(false);
|
||||
expect(selectUserId(state)).toBeNaN();
|
||||
expect(selectToken(state)).toBeNull();
|
||||
expect(selectUsername(state)).toBeNull();
|
||||
|
@ -22,6 +23,7 @@ describe('session selectors', () => {
|
|||
expect(selectUserId(state)).toBe(1);
|
||||
expect(selectUsername(state)).toBe('user1-username');
|
||||
expect(selectToken(state)).toBe('user1-token');
|
||||
expect(selectIsLoggedIn(state)).toBe(true);
|
||||
});
|
||||
|
||||
describe('permissions', () => {
|
||||
|
|
Loading…
Reference in a new issue