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的更多相关文章

  1. [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 ...

  2. [Angular] Testing @Input and @Output bindings

    Component: import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output } from '@angular ...

  3. [Angular Unit Testing] Testing Component methods

    import {ComponentFixture, TestBed} from '@angular/core/testing'; import {BrowserDynamicTestingModule ...

  4. [Angular Unit Testing] Testing Services with dependencies

    import { Http, Response, ResponseOptions } from '@angular/http'; import { TestBed } from '@angular/c ...

  5. 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 ...

  6. [AngularJS Unit tesint] Testing keyboard event

    HTML: <div ng-focus="vm.onFocus(month)", aria-focus="{{vm.focus == month}}", ...

  7. [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 ...

  8. [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 ...

  9. [AngularJS + Unit Testing] Testing a component with requiring ngModel

    The component test: describe('The component test', () => { let component, $componentController, $ ...

随机推荐

  1. mysql主从同步错误恢复

    Mysql主从同步集群在生成环境使用过程中,如果主从服务器之间网络通信条件差或者数据库数据量非常大,容易导致MYSQL主从同步延迟. MYSQL主从产生延迟之后,一旦主库宕机,会导致部分数据没有及时同 ...

  2. mysql更改密码与远程管理

    set password = ': #在当前用户下更改密码 grant all privileges on *.* to root@"%" identified by " ...

  3. shiro整合thymeleaf

    1.引入依赖 <!--thymeleaf中使用shiro--> <dependency> <groupId>com.github.theborakompanioni ...

  4. Java基础学习总结(29)——浅谈Java中的Set、List、Map的区别

    就学习经验,浅谈Java中的Set,List,Map的区别,对JAVA的集合的理解是想对于数组: 数组是大小固定的,并且同一个数组只能存放类型一样的数据(基本类型/引用类型),JAVA集合可以存储和操 ...

  5. ArcGIS api for javascript——明确的创建图层列表

    描述 本例展示了如何确切地创建一个地图服务里的图层列表.这个列表由HTML checkboxe组成,可用用于开关图层的可见性. 函数updateLayerVisibility()包含开关图层的逻辑.函 ...

  6. Effective JavaScript Item 40 避免继承标准类型

    本系列作为Effective JavaScript的读书笔记. ECMAScript标准库不大.可是提供了一些重要的类型如Array,Function和Date.在一些场合下.你或许会考虑继承当中的某 ...

  7. 封装html代码块到js函数中

    有时候想把公共的html封装起来,怎么处理呢? 好多页面都用到,不可能每个页面都写,这样就会有冗余,并且不好统一处理. 那就用js来重构html吧. 代码案例如下: <footer class= ...

  8. hdoj--2682--Tree()

    Tree Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  9. Centos7 ssh免密码登陆

    摘要:安装openssl openssl-devel 不过有些centos自带 192.168.161.5  192.168.161.15 本版本用centos7 (192.168.161.5) yu ...

  10. Java反射异常处理之InvocationTargetException

    java.lang.reflect.InvocationTargetException处理办法可能是没有引commons-lang3-3.x.jar包