• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript redux-saga-test-plan.testSaga函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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()
 })
开发者ID:czb128abc,项目名称:gouqi,代码行数:35,代码来源:recommend.test.ts


示例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()
})
开发者ID:czb128abc,项目名称:gouqi,代码行数:35,代码来源:playlist.test.ts


示例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();
      });
开发者ID:a6802739,项目名称:cockroach,代码行数:34,代码来源:metrics.spec.ts


示例4: test

 test('empty user or pwd', () => {
   testSaga(loginFlow, { payload: { username: '', password: '' } })
     .next()
     .put(actions.toastAction('warning', '帐号或密码不能为空'))
     .next()
     .isDone()
 })
开发者ID:czb128abc,项目名称:gouqi,代码行数:7,代码来源:main.test.ts


示例5: it

 it("initially processes first action", function() {
     const state = new ManagedQuerySagaState();
     state.channel = channel<any>();
     testSaga(processQueryManagementAction, state)
         .next()
         .take(state.channel);
 });
开发者ID:asubiotto,项目名称:cockroach,代码行数:7,代码来源:saga.spec.ts


示例6: test

 test('watchCurrentTime', () => {
   testSaga(watchCurrentTime)
     .next()
     .put(actions.addSecondsAction())
     .next()
     .isDone()
 })
开发者ID:czb128abc,项目名称:gouqi,代码行数:7,代码来源:player.test.ts


示例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()
 })
开发者ID:czb128abc,项目名称:gouqi,代码行数:28,代码来源:search.test.ts



注:本文中的redux-saga-test-plan.testSaga函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap