本文整理匯總了TypeScript中redux-saga-test-plan.testSaga函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript testSaga函數的具體用法?TypeScript testSaga怎麽用?TypeScript testSaga使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了testSaga函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('ajax success', () => {
testSaga(syncMoreArtists)
.next()
.select(artistsOffsetSelector)
.next(artistsOffsetSelector(state))
.put({
type: 'home/recommend/start'
})
.next()
.save('ajax')
.next({
code: 200,
albums: [],
more: true
})
.put({
type: 'home/artists/save',
payload: [],
meta: 130
})
.next()
.restore('ajax')
.next({
code: 200,
albums: [],
more: false
})
.put(actions.toastAction('info', '所有內容已經加載完畢。'))
.next()
.put({
type: 'home/recommend/end'
})
.next()
.isDone()
})
示例2: test
test('unsubscribePlaylist', () => {
const payload = 1
testSaga(subscribePlaylist)
.next()
.take('details/playlist/subscribe')
.next({ payload })
.select(playlistSelector)
.next({
[payload]: {
subscribed: true,
subscribedCount: 100
}
})
.put({
type: 'details/subscribe/start'
})
.next()
.next({ code: 200 })
.put({
type: 'details/playlist/save',
payload: {
[payload]: {
subscribedCount: 99,
subscribed: false
}
}
})
.next()
.put({
type: 'details/subscribe/end'
})
.next()
.finish()
.isDone()
})
示例3: it
it("sendBatches correctly batches multiple requests", function () {
const shortRequests = [
metrics.requestMetrics("id", createRequest(shortTimespan, "short.1")).payload,
metrics.requestMetrics("id", createRequest(shortTimespan, "short.2", "short.3")).payload,
metrics.requestMetrics("id", createRequest(shortTimespan, "short.4")).payload,
];
const longRequests = [
metrics.requestMetrics("id", createRequest(longTimespan, "long.1")).payload,
metrics.requestMetrics("id", createRequest(longTimespan, "long.2", "long.3")).payload,
metrics.requestMetrics("id", createRequest(longTimespan, "long.4", "long.5")).payload,
];
// Mix the requests together and send the combined request set.
const mixedRequests = _.flatMap(shortRequests, (short, i) => [short, longRequests[i]]);
testSaga(metrics.batchAndSendRequests, mixedRequests)
// sendBatches next puts a "fetchMetrics" action into the store.
.next()
.put(metrics.fetchMetrics())
.next()
// Next, sendBatches dispatches a "all" effect with a "call" for each
// batch; there should be two batches in total, one containing the
// short requests and one containing the long requests. The order of
// requests in each batch is maintained.
.all([
call(metrics.sendRequestBatch, shortRequests),
call(metrics.sendRequestBatch, longRequests),
])
// After completion, puts "fetchMetricsComplete" to store.
.next()
.put(metrics.fetchMetricsComplete())
.next()
.isDone();
});
示例4: test
test('empty user or pwd', () => {
testSaga(loginFlow, { payload: { username: '', password: '' } })
.next()
.put(actions.toastAction('warning', '帳號或密碼不能為空'))
.next()
.isDone()
})
示例5: it
it("initially processes first action", function() {
const state = new ManagedQuerySagaState();
state.channel = channel<any>();
testSaga(processQueryManagementAction, state)
.next()
.take(state.channel);
});
示例6: test
test('watchCurrentTime', () => {
testSaga(watchCurrentTime)
.next()
.put(actions.addSecondsAction())
.next()
.isDone()
})
示例7: test
test('nothing found', () => {
testSaga(syncSearchSongs)
.next()
.take(`search/${reducerType}`)
.next()
.select(searchSelector)
.next(state)
.put({
type: `search/${reducerType}/start`
})
.next()
.save('ajax')
.next({
code: 200,
result: {
songs: undefined,
songCount: 200
}
})
.put(actions.toastAction('info', '什麽也找不到'))
.next()
.put({
type: `search/${reducerType}/end`
})
.next()
.finish()
.isDone()
})