[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, $ ...
随机推荐
- 前端之CSS属性相关
宽和高 width属性可以为元素设置宽度. height属性可以为元素设置高度. 块级标签才能设置宽度,内联标签的宽度由内容来决定. 字体属性 文字字体 font-family可以把多个字体名称作为一 ...
- 用xstart远程连接linux图形用户界面时发生已经在使用的情况
1.举例打开pycharm 2.此时要输入ps aux|grep pycharm,出现下面的情况 3.然后找到矩形圈住的内容,然后输入 这样就杀掉了远程机子上pycharm,接着继续输入pycharm ...
- win7 ssd评分降为5.9的诡异问题解决方法
某一天偶然发现win7的系统评分里面,磁盘一项由之前的7.9降到5.9了,SSD早听说会有降速的问题,但无论如何降,也不至于被降到5.9分这一机械硬盘普遍的分数. 百度搜了,Google搜了,中文搜了 ...
- Android组件Activity初探
1.Activity是什么 Activity是Android系统中的四大组件之一,在MVC模式中属于C控制层 M(Model 模型):Model是应用程序的主体对象. V(View 视图) ...
- ArcGIS api for javascript——设置自定义范围和空间参考
描述 这个示例展示了在创建地图时如果定义一个自定义的范围和空间参考. 在 ArcGIS JavaScript API的1.0和1.1版本,任何要使用的地图服务图层都需要和地图的空间参考一致.1.2版本 ...
- typedef 与 set_new_handler的几种写法
可以用Command模式.函数对象来代替函数指针,获得以下的好处: 1. 可以封装数据 2. 可以通过虚拟成员获得函数的多态性 3. 可以处理类层次结果,将Command与Prototype模式相结合 ...
- VGA接口时序约束
SF-VGA模块板载VGA显示器DA转换驱动芯片AVD7123,FPGA通过OUPLLN连接器驱动ADV7123芯片产生供给VGA显示器的色彩以及同步信号.SF-CY3核心模块与SF-VGA子模块连接 ...
- css如何实现垂直居中(5种方法)
css如何实现垂直居中(5种方法) 一.总结 一句话总结:行内只需要简单地把 line-height 设置为那个对象的 height 值就可以使文本居中了. 块的话可以尝试 margin:auto: ...
- vSphere5安装配置视频教程
vSphere5安装配置视频教程 本文出自 "李晨光原创技术博客" 博客,请务必保留此出处http://chenguang.blog.51cto.com/350944/819550
- ipad 基础
一.必备技巧 1.死机重启苹果的东西都比较稳定,但这并不等于iPad不会死机.死机了怎么办?iPad电池可是内置的,后盖一般用户也打不开.方法是:按住机身顶端的电源键和圆形的HOME键几秒钟,这时iP ...