[Redux-Observable && Unit testing] Testing the output of epics
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();
});
});
[Redux-Observable && Unit testing] Testing the output of epics的更多相关文章
- [Angular & Unit Testing] Testing a RouterOutlet component
The way to test router componet needs a little bit setup, first we need to create a "router-stu ...
- [Angular] Testing @Input and @Output bindings
Component: import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output } from '@angular ...
- [Angular Unit Testing] Testing Component methods
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {BrowserDynamicTestingModule ...
- [Angular Unit Testing] Testing Services with dependencies
import { Http, Response, ResponseOptions } from '@angular/http'; import { TestBed } from '@angular/c ...
- Run Unit API Testing Which Was Distributed To Multiple Test Agents
Recently I am blocked by a very weird issue, from the VS installed machine, I can run performance te ...
- [AngularJS Unit tesint] Testing keyboard event
HTML: <div ng-focus="vm.onFocus(month)", aria-focus="{{vm.focus == month}}", ...
- [Angular & Unit Testing] Testing Component with Store
When using Ngrx, we need to know how to test the component which has Router injected. Component: imp ...
- [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope
<div> <h2>{{vm.userInfo.number}} - {{vm.userInfo.name}}</h2> </div> 'use str ...
- [AngularJS + Unit Testing] Testing a component with requiring ngModel
The component test: describe('The component test', () => { let component, $componentController, $ ...
随机推荐
- [NOIP2015提高组]子串
题目:洛谷P2679.Vijos P1982.codevs4560.UOJ#149. 题目大意:有长度为n的A串和长度为m的B串.现在要从A串中取出k个互不重叠的子串,使它们按顺序相连后得到B串.问有 ...
- Symfony4中文文档: 安装和设置Symfony框架
安装和设置Symfony框架 要创建新的Symfony应用程序, 首先确保使用的是PHP7.1 或更高版本并且已经安装Componser. 如果未安装, 请首先在系统上全局安装Componser. 如 ...
- ArcGIS api for javascript——合并两个ArcGIS Online服务
描述 这个示例创建一个地图并ArcGIS Online增加连个图层到地图.ArcGIS Online是由ESRI体提供的一组切片地图服务,可以用来通过高质量的地图和数据增强应用.这个示例增加影像和运输 ...
- 局部特化 & 特化
注意,显式特化不是一个模板.如果是类型跟显式特化一样,那么不是实例化. 显式特化类的函数,不需要再加template,因为不是模板方法. 特化类的函数跟模板类不一定要一样,但是一样更好. 不支持局部特 ...
- UE4的JSON读写方式<一>
声明:全部权利保留. 转载必须说明出处:http://blog.csdn.net/cartzhang/article/details/41009343 UE4的Json的解析博客地址: http:// ...
- TortoiseSvn安装的时候,将svn的命令行工具单独隔离出来
https://stackoverflow.com/questions/2967176/where-is-svn-exe-in-my-machine The subversion program co ...
- legend---三、方法集思路
legend---三.方法集思路 一.总结 一句话总结:其实也就是工具包思路,会极大的简化编程,清晰逻辑 1.多if转换成简洁单if怎么实现? 下面这段代码是错的,if的这种写法只适合直接return ...
- oh-my-zsh upgrade problem
Oh-My-ZSH upgrade issue with bad substitution message Any problem with automatic Oh-My-Zsh upgrade ...
- 不允许 ASSIGNMENT 语句中包含 FOR XML 子句。
DECLARE @guidList NVARCHAR(max) SELECT @guidList=( CAST(OrderGUID AS nvarchar(max)) +',') FROM Order ...
- 963B:Destruction of a Tree
You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any ve ...