Epics can be unit-tested just like any other function in your application - they have a very specific set of inputs (the action$ stream) and the output is always an Observable. We can subscribe to this output Observable to assert that the actions going back into the Redux are the ones we expect.

export function fetchUserEpic(action$) {
return action$.ofType('FETCH_USER')
.map(action => ({
type: 'FETCH_USER_FULFILLED',
payload: {
name: 'Shane',
user: action.payload
}
}))
}
import {Observable} from 'rxjs';
import {ActionsObservable} from 'redux-observable';
import {fetchUserEpic} from "./fetch-user-epic";
it('should return correct actions', function () {
const action$ = ActionsObservable.of({
type: 'FETCH_USER',
payload: 'shakyshane'
}); const output$ = fetchUserEpic(action$);
output$.toArray().subscribe(actions => {
expect(actions.length).toBe();
});
});

最新文章

  1. C#开发微信门户及应用(43)--微信各个项目模块的定义和相互关系
  2. Struts2 自定义MVC框架
  3. eclipse中一些设置&配置项
  4. poj1416 Shredding Company
  5. 如何确定C#代码是在编译时执行还是在运行时执行
  6. 更加优雅地搭建SSH框架(使用java配置)
  7. 正确对待bug
  8. 转:ASP.NET MVC扩展之HtmlHelper辅助方法
  9. 【转】在企业内部分发 iOS 应用程序
  10. HDOJ(HDU) 4847 Wow! Such Doge!(doge字符统计)
  11. javascript中的动画的实现以及运动框架的编写(1)
  12. B树及B+树
  13. MyBaits集合的嵌套 Select 查询
  14. PSP耗时
  15. SharePoint 2016 - 安装QuickFlow2013
  16. C语言编程知识点
  17. express文件上传中间件Multer详解
  18. HTML5 Canvas水波纹动画特效
  19. hive中窗口分析函数
  20. bzoj3751 / P2312 解方程

热门文章

  1. [BZOJ2821]作诗(分块)
  2. python 异步IO
  3. Python 读写文件 小应用:生成随机的测验试卷文件
  4. 用JS中的cookie实现商品的浏览记录
  5. 洛谷——P1965 转圈游戏
  6. 洛谷 P2440 木材加工
  7. 《JSP+Servlet+Tomcat应用开发从零開始学》
  8. Java编程手冊-Collection框架(下)
  9. C语言:具体解释指针
  10. 彻底解决lazarus安装组件后烦人的编译时单元找不到的问题!