Commit cace4483 authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Fix event unit tests

parent ebf84ae8
import { select } from 'redux-saga/effects';
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 } from '../../app/url';
import { apiRequest, tokenSelector } from '../../app/url';
import eventSaga from '../../app/sagas/event';
import * as eventActions from '../../app/actions/event';
......@@ -14,6 +15,7 @@ describe('event api call', () => {
it('should start fetching', () => expectSaga(eventSaga)
.provide([
[select(tokenSelector), 'token'],
[matchers.call.fn(apiRequest), []],
])
.dispatch(eventActions.event(1))
......@@ -22,6 +24,7 @@ describe('event api call', () => {
it('should navigate to the event scene', () => expectSaga(eventSaga)
.provide([
[select(tokenSelector), 'token'],
[matchers.call.fn(apiRequest), []],
])
.dispatch(eventActions.event(1))
......@@ -30,18 +33,20 @@ describe('event api call', () => {
it('should put an error when the api request fails', () => expectSaga(eventSaga)
.provide([
[select(tokenSelector), 'token'],
[matchers.call.fn(apiRequest), throwError(error)],
])
.dispatch(eventActions.event(1, 'token'))
.dispatch(eventActions.event(1))
.put(eventActions.failure())
.silentRun());
it('should put the result data when the request succeeds', () => expectSaga(eventSaga)
.provide([
[select(tokenSelector), 'token'],
[matchers.call.like({ fn: apiRequest, args: ['events/1'] }), 'eventData'],
[matchers.call.like({ fn: apiRequest, args: ['events/1/registrations'] }), 'regData'],
])
.dispatch(eventActions.event(1, 'token'))
.dispatch(eventActions.event(1))
.put(eventActions.success('eventData', 'regData'))
.silentRun());
});
......@@ -159,8 +159,8 @@ class Event extends Component {
// Needed once registration on server implemented
if (regAllowed) {
if (event.user_registration === null || event.user_registration.is_cancelled) {
const text = event.max_participants && event.max_participants > event.num_participants ?
'Aanmelden' : 'Zet me op de wachtlijst';
const text = event.max_participants && event.max_participants <= event.num_participants ?
'Zet me op de wachtlijst' : 'Aanmelden';
return (
<View style={styles.registrationActions}>
<Button
......
Supports Markdown
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