-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
104 additions
and
85 deletions.
There are no files selected for viewing
33 changes: 22 additions & 11 deletions
33
app/containers/Api/tests/sagas.test.js → app/containers/Api/tests/sagas.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,48 @@ | ||
// @flow | ||
import { call, put } from 'redux-saga/effects' | ||
import * as api from 'services/api' | ||
import { getToken } from 'containers/LoginModal/saga' | ||
import * as sagas from '../sagas' | ||
import * as actions from '../actions' | ||
|
||
test('post', () => { | ||
const gen = sagas.post('endpoint', { dummy: 1 }) | ||
|
||
const gen = sagas.post('endpoint', { | ||
dummy: 1, | ||
}) | ||
let next = gen.next() | ||
expect(next.value).toStrictEqual(call(getToken)) | ||
|
||
const token = 'fake token' | ||
next = gen.next(token) | ||
expect(next.value).toStrictEqual( | ||
call(api.postRequest, 'endpoint', { dummy: 1 }, token) | ||
call( | ||
api.postRequest, | ||
'endpoint', | ||
{ | ||
dummy: 1, | ||
}, | ||
token | ||
) | ||
) | ||
}) | ||
|
||
test('get', () => { | ||
const gen = sagas.get('endpoint', true) | ||
|
||
let next = gen.next() | ||
expect(next.value).toStrictEqual(call(getToken)) | ||
|
||
const token = 'fake token' | ||
next = gen.next(token) | ||
expect(next.value).toStrictEqual(call(api.getRequest, 'endpoint', {}, token)) | ||
expect(next.value).toStrictEqual(call(api.getRequest, 'endpoint', {}, token)) // $FlowFixMe | ||
|
||
// $FlowFixMe | ||
next = gen.next({ entities: {}, result: {} }) | ||
next = gen.next({ | ||
entities: {}, | ||
result: {}, | ||
}) | ||
expect(next.value).toStrictEqual( | ||
// $FlowFixMe | ||
put(actions.apiRequestSuccess({ entities: {}, result: {} })) | ||
put( | ||
actions.apiRequestSuccess({ | ||
entities: {}, | ||
result: {}, | ||
}) | ||
) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ntainers/BoxContainer/tests/sagas.test.js → ...tainers/BoxContainer/tests/sagas.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// @flow | ||
import * as sagas from '../saga' | ||
|
||
test('root', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...ntainers/ColumnFollow/tests/sagas.test.js → ...tainers/ColumnFollow/tests/sagas.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ners/ColumnRankingR18/tests/sagas.test.js → ...ers/ColumnRankingR18/tests/sagas.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ers/ColumnRecommended/tests/sagas.test.js → ...rs/ColumnRecommended/tests/sagas.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 12 additions & 15 deletions
27
...ntainers/FollowButton/tests/sagas.test.js → ...tainers/FollowButton/tests/sagas.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,56 @@ | ||
// @flow | ||
import { takeEvery, put } from 'redux-saga/effects' | ||
import * as sagas from '../saga' | ||
import * as constants from '../constants' | ||
import * as actions from '../actions' | ||
|
||
test('root', () => { | ||
const gen = sagas.default() | ||
|
||
let next = gen.next() | ||
expect(next.value).toStrictEqual( | ||
takeEvery(constants.FOLLOW_REQUEST, sagas.follow) | ||
) | ||
|
||
next = gen.next() | ||
expect(next.value).toStrictEqual( | ||
takeEvery(constants.UN_FOLLOW_REQUEST, sagas.unfollow) | ||
) | ||
}) | ||
|
||
test('follow success', () => { | ||
const gen = sagas.follow({ id: 1 }) | ||
|
||
const gen = sagas.follow({ | ||
id: 1, | ||
}) | ||
let next = gen.next() | ||
expect(next.value).toMatchSnapshot() | ||
|
||
next = gen.next() | ||
expect(next.value).toStrictEqual(put(actions.followSuccess('public'))) | ||
}) | ||
|
||
test('follow failer', () => { | ||
const gen = sagas.follow({ id: 1 }) | ||
|
||
const gen = sagas.follow({ | ||
id: 1, | ||
}) | ||
let next = gen.next() | ||
expect(next.value).toMatchSnapshot() | ||
|
||
next = gen.throw('err') | ||
expect(next.value).toStrictEqual(put(actions.followFailer('err'))) | ||
}) | ||
|
||
test('unfollow success', () => { | ||
const gen = sagas.unfollow({ id: 1 }) | ||
|
||
const gen = sagas.unfollow({ | ||
id: 1, | ||
}) | ||
let next = gen.next() | ||
expect(next.value).toMatchSnapshot() | ||
|
||
next = gen.next() | ||
expect(next.value).toStrictEqual(put(actions.unFollowSuccess('public'))) | ||
}) | ||
|
||
test('unfollow failer', () => { | ||
const gen = sagas.unfollow({ id: 1 }) | ||
|
||
const gen = sagas.unfollow({ | ||
id: 1, | ||
}) | ||
let next = gen.next() | ||
expect(next.value).toMatchSnapshot() | ||
|
||
next = gen.throw('err') | ||
expect(next.value).toStrictEqual(put(actions.unFollowFailer('err'))) | ||
}) |
Oops, something went wrong.