本文整理汇总了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()
})