Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
43e5ebbd
Commit
43e5ebbd
authored
Sep 07, 2018
by
Gijs Hendriksen
Browse files
Fixed loggedInSelector and moved selectors to separate file
parent
8dc5492f
Changes
23
Hide whitespace changes
Inline
Side-by-side
__tests__/sagas/calendar.spec.js
View file @
43e5ebbd
...
...
@@ -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
'
,
}));
...
...
__tests__/sagas/event.spec.js
View file @
43e5ebbd
...
...
@@ -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
'
);
...
...
__tests__/sagas/pizza.spec.js
View file @
43e5ebbd
...
...
@@ -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
;
...
...
__tests__/sagas/profile.spec.js
View file @
43e5ebbd
...
...
@@ -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
'
);
...
...
__tests__/sagas/pushNotifications.spec.js
View file @
43e5ebbd
...
...
@@ -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
'
,
}));
...
...
__tests__/sagas/registration.spec.js
View file @
43e5ebbd
...
...
@@ -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
'
,
}));
...
...
__tests__/sagas/session.spec.js
View file @
43e5ebbd
...
...
@@ -29,6 +29,9 @@ jest.mock('react-native', () => ({
jest
.
mock
(
'
../../app/utils/url
'
,
()
=>
({
apiRequest
:
jest
.
fn
(()
=>
{}),
}));
jest
.
mock
(
'
../../app/selectors/session
'
,
()
=>
({
tokenSelector
:
()
=>
'
abc123
'
,
}));
...
...
__tests__/sagas/welcome.spec.js
View file @
43e5ebbd
...
...
@@ -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
'
,
}));
...
...
__tests__/selectors/session.spec.js
0 → 100644
View file @
43e5ebbd
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
);
});
});
__tests__/utils/url.spec.js
View file @
43e5ebbd
...
...
@@ -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
)
...
...
app/sagas/calendar.js
View file @
43e5ebbd
...
...
@@ -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
);
...
...
app/sagas/deepLinking.js
View file @
43e5ebbd
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
'
;
...
...
app/sagas/event.js
View file @
43e5ebbd
...
...
@@ -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
;
...
...
app/sagas/members.js
View file @
43e5ebbd
...
...
@@ -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
;
...
...
app/sagas/pizza.js
View file @
43e5ebbd
...
...
@@ -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
;
...
...
app/sagas/profile.js
View file @
43e5ebbd
...
...
@@ -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
;
...
...
app/sagas/pushNotifications.js
View file @
43e5ebbd
...
...
@@ -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
();
...
...
app/sagas/registration.js
View file @
43e5ebbd
...
...
@@ -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
;
...
...
app/sagas/session.js
View file @
43e5ebbd
...
...
@@ -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
'
;
...
...
app/sagas/settings.js
View file @
43e5ebbd
...
...
@@ -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
'
;
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment