scratch-www/test/unit/redux/permissions.test.js
2021-03-23 15:18:17 -04:00

31 lines
979 B
JavaScript

import {
selectIsAdmin, selectIsSocial, permissionsReducer, setPermissions
} from '../../../src/redux/permissions';
describe('permission selectors', () => {
test('all permissions are initially false', () => {
const state = {
permissions: {}
};
expect(selectIsAdmin(state)).toBe(false);
expect(selectIsSocial(state)).toBe(false);
});
test('selectIsAdmin', () => {
let state = {
permissions: {}
};
const newPermissions = {admin: true};
state.permissions = permissionsReducer(state.session, setPermissions(newPermissions));
expect(selectIsAdmin(state)).toBe(true);
});
test('isSocial', () => {
let state = {
permissions: {}
};
const newPermissions = {social: true};
state.permissions = permissionsReducer(state.session, setPermissions(newPermissions));
expect(selectIsSocial(state)).toBe(true);
});
});