Commit 43e5ebbd authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Fixed loggedInSelector and moved selectors to separate file

parent 8dc5492f
......@@ -3,13 +3,17 @@ import { expectSaga } from 'redux-saga-test-plan';
import * as matchers from 'redux-saga-test-plan/matchers';
import { throwError } from 'redux-saga-test-plan/providers';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import calendarSaga from '../../app/sagas/calendar';
import * as calendarActions from '../../app/actions/calendar';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
......
......@@ -3,20 +3,24 @@ import { expectSaga } from 'redux-saga-test-plan';
import * as matchers from 'redux-saga-test-plan/matchers';
import { throwError } from 'redux-saga-test-plan/providers';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import eventSaga from '../../app/sagas/event';
import * as eventActions from '../../app/actions/event';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
tokenSelector: () => 'token',
}));
jest.mock('../../app/navigation', () => ({
navigate: jest.fn(),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
describe('event saga', () => {
const error = new Error('error');
......
......@@ -2,19 +2,23 @@ import * as matchers from 'redux-saga-test-plan/matchers';
import { select } from 'redux-saga/effects';
import { expectSaga } from 'redux-saga-test-plan';
import { throwError } from 'redux-saga-test-plan/providers';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import pizzaSaga from '../../app/sagas/pizza';
import * as pizzaActions from '../../app/actions/pizza';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
tokenSelector: () => 'token',
}));
jest.mock('../../app/navigation', () => ({
navigate: jest.fn(),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
describe('pizza saga', () => {
const error = new Error('error');
error.response = null;
......
......@@ -3,18 +3,22 @@ import { expectSaga } from 'redux-saga-test-plan';
import * as matchers from 'redux-saga-test-plan/matchers';
import { throwError } from 'redux-saga-test-plan/providers';
import profileSaga from '../../app/sagas/profile';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import * as profileActions from '../../app/actions/profile';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
tokenSelector: () => 'token',
}));
jest.mock('../../app/navigation', () => ({
navigate: jest.fn(),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
describe('profile saga', () => {
const error = new Error('error');
......
......@@ -3,11 +3,15 @@ import { expectSaga } from 'redux-saga-test-plan';
import * as matchers from 'redux-saga-test-plan/matchers';
import { Platform } from 'react-native';
import pushNotificationsSaga from '../../app/sagas/pushNotifications';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import * as pushActions from '../../app/actions/pushNotifications';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
......
......@@ -5,8 +5,9 @@ import Snackbar from 'react-native-snackbar';
import { select } from 'redux-saga/effects';
import * as registrationActions from '../../app/actions/registration';
import registrationSaga, { eventSelector } from '../../app/sagas/registration';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import * as eventActions from '../../app/actions/event';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('react-native-snackbar', () => ({
LENGTH_LONG: 100,
......@@ -21,6 +22,9 @@ jest.mock('../../app/navigation', () => ({
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
......
......@@ -29,6 +29,9 @@ jest.mock('react-native', () => ({
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'abc123',
}));
......
......@@ -3,11 +3,15 @@ import { expectSaga } from 'redux-saga-test-plan';
import * as matchers from 'redux-saga-test-plan/matchers';
import { throwError } from 'redux-saga-test-plan/providers';
import welcomeSaga from '../../app/sagas/welcome';
import { apiRequest, tokenSelector } from '../../app/utils/url';
import { apiRequest } from '../../app/utils/url';
import * as welcomeActions from '../../app/actions/welcome';
import { tokenSelector } from '../../app/selectors/session';
jest.mock('../../app/utils/url', () => ({
apiRequest: jest.fn(() => {}),
}));
jest.mock('../../app/selectors/session', () => ({
tokenSelector: () => 'token',
}));
......
import {
tokenSelector,
loggedInSelector,
} from '../../app/selectors/session';
import { STATUS_SIGNED_IN } from '../../app/reducers/session';
describe('session selectors', () => {
it('should expose the selectors', () => {
expect(tokenSelector({ session: { token: 'abc123' } })).toEqual('abc123');
expect(loggedInSelector({ session: { status: STATUS_SIGNED_IN } })).toEqual(true);
});
});
......@@ -2,9 +2,7 @@ import {
apiRequest,
apiUrl,
defaultProfileImage,
loggedInSelector,
ServerError,
tokenSelector,
url,
} from '../../app/utils/url';
......@@ -29,11 +27,6 @@ describe('url helper', () => {
expect(defaultProfileImage).toEqual('http://localhost:8000/static/members/images/default-avatar.jpg');
});
it('should expose the selectors', () => {
expect(tokenSelector({ session: { token: 'abc123' } })).toEqual('abc123');
expect(loggedInSelector({ navigation: { loggedIn: true } })).toEqual(true);
});
it('should do a fetch request', () => {
expect.assertions(2);
return apiRequest('route', {}, null)
......
......@@ -3,8 +3,9 @@ import {
} from 'redux-saga/effects';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as calendarActions from '../actions/calendar';
import { tokenSelector } from '../selectors/session';
const calendar = function* calendar() {
const token = yield select(tokenSelector);
......
import {
put, take, takeEvery, select,
} from 'redux-saga/effects';
import { url as siteURL, loggedInSelector } from '../utils/url';
import { url as siteURL } from '../utils/url';
import { loggedInSelector } from '../selectors/session';
import * as deepLinkingActions from '../actions/deepLinking';
import * as pizzaActions from '../actions/pizza';
......
......@@ -3,8 +3,9 @@ import {
} from 'redux-saga/effects';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as eventActions from '../actions/event';
import { tokenSelector } from '../selectors/session';
const event = function* event(action) {
const { pk } = action.payload;
......
......@@ -7,8 +7,9 @@ import { Sentry } from 'react-native-sentry';
import { TOTAL_BAR_HEIGHT } from '../ui/components/standardHeader/style/StandardHeader';
import { memberSize } from '../ui/screens/memberList/style/MemberList';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as memberActions from '../actions/members';
import { tokenSelector } from '../selectors/session';
const members = function* members(action) {
const { keywords } = action.payload;
......
......@@ -2,9 +2,10 @@ import {
call, put, select, takeEvery,
} from 'redux-saga/effects';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as pizzaActions from '../actions/pizza';
import { tokenSelector } from '../selectors/session';
const NOT_FOUND = 404;
......
......@@ -3,8 +3,9 @@ import {
} from 'redux-saga/effects';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as profileActions from '../actions/profile';
import { tokenSelector } from '../selectors/session';
const profile = function* profile(action) {
const { member } = action.payload;
......
......@@ -3,8 +3,9 @@ import { Platform } from 'react-native';
import firebase from 'react-native-firebase';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as pushNotificationsActions from '../actions/pushNotifications';
import { tokenSelector } from '../selectors/session';
const register = function* register(action) {
const messaging = firebase.messaging();
......
......@@ -5,10 +5,11 @@ import {
import Snackbar from 'react-native-snackbar';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as eventActions from '../actions/event';
import * as registrationActions from '../actions/registration';
import { tokenSelector } from '../selectors/session';
export const eventSelector = state => state.event.data.pk;
......
......@@ -6,9 +6,10 @@ import { AsyncStorage } from 'react-native';
import Snackbar from 'react-native-snackbar';
import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as sessionActions from '../actions/session';
import * as pushNotificationsActions from '../actions/pushNotifications';
import { tokenSelector } from '../selectors/session';
export const USERNAMEKEY = '@MyStore:username';
export const TOKENKEY = '@MyStore:token';
......
......@@ -6,8 +6,9 @@ import {
import { notificationsSettingsActions, settingsActions } from '../actions/settings';
import { apiRequest, tokenSelector } from '../utils/url';
import { apiRequest } from '../utils/url';
import * as pushNotifactionsActions from '../actions/pushNotifications';
import { tokenSelector } from '../selectors/session';
const PUSHCATEGORYKEY = '@MyStore:pushCategories';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment