forked from abalone0204/Clairvoyance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sagas): Add transaction of fetching comments after fetch or crea…
…te job successfully
- Loading branch information
1 parent
ecd5d3e
commit 57e58f9
Showing
6 changed files
with
154 additions
and
17 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
takeEvery | ||
} from 'redux-saga' | ||
|
||
import { | ||
put, | ||
call | ||
} from 'redux-saga/effects' | ||
|
||
import { | ||
SUCCESS_CREATE_JOB | ||
} from '../actions/createJob.js' | ||
|
||
import { | ||
SUCCESS_FETCH_JOB | ||
} from '../actions/fetchJob.js' | ||
|
||
import { | ||
requestFetchComments | ||
} from '../actions/fetchComments.js' | ||
|
||
export function* transactionOfJobAndComments() { | ||
yield call(takeEvery, [SUCCESS_CREATE_JOB, SUCCESS_FETCH_JOB], sendRequestToFetchComments) | ||
} | ||
|
||
export function* sendRequestToFetchComments(action) { | ||
yield put(requestFetchComments(action.job.id)) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'babel-polyfill' | ||
|
||
import { | ||
assert | ||
} from 'chai' | ||
|
||
import { | ||
takeEvery | ||
} from 'redux-saga' | ||
|
||
import { | ||
put, | ||
call | ||
} from 'redux-saga/effects' | ||
|
||
import { | ||
SUCCESS_CREATE_JOB | ||
} from 'actions/createJob.js' | ||
|
||
import { | ||
SUCCESS_FETCH_JOB | ||
} from 'actions/fetchJob.js' | ||
|
||
import { | ||
requestFetchComments | ||
} from 'actions/fetchComments.js' | ||
|
||
import { | ||
transactionOfJobAndComments, | ||
sendRequestToFetchComments | ||
} from 'sagas/transactionFlows' | ||
|
||
describe('Sagas/ Transaction flows', () => { | ||
describe('transactionOfJobAndComments', () => { | ||
const iterator = transactionOfJobAndComments() | ||
|
||
it('should watch success effect of fetching and creating job, and call sendRequestToFetchComments', () => { | ||
const expected = call(takeEvery, [SUCCESS_CREATE_JOB, SUCCESS_FETCH_JOB], sendRequestToFetchComments) | ||
const actual = iterator.next().value | ||
assert.deepEqual(expected, actual) | ||
}) | ||
}) | ||
}) |