当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript brookjs-desalinate.chaiPlugin函数代码示例

本文整理汇总了TypeScript中brookjs-desalinate.chaiPlugin函数的典型用法代码示例。如果您正苦于以下问题:TypeScript chaiPlugin函数的具体用法?TypeScript chaiPlugin怎么用?TypeScript chaiPlugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了chaiPlugin函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: chaiPlugin

/* eslint-env mocha */
import { expect, use } from 'chai';
import { chaiPlugin } from 'brookjs-desalinate';
import Kefir from 'kefir';
import ofType from '../ofType';

const { plugin, send, value, stream } = chaiPlugin({ Kefir });
use(plugin);

describe('ofType', () => {
  it('should match when passing one type', () => {
    const action$ = stream();

    expect(action$.thru(ofType('MATCHED'))).to.emit(
      [value({ type: 'MATCHED' })],
      () => {
        send(action$, [
          value({ type: 'UNMATCHED' }),
          value({ type: 'MATCHED' })
        ]);
      }
    );
  });

  it('should match when passing one type with Function#toString', () => {
    const matched = () => ({ type: 'MATCHED' });
    matched.toString = () => 'MATCHED';
    const action$ = stream();

    expect(action$.thru(ofType(matched))).to.emit(
      [value({ type: 'MATCHED' })],
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:31,代码来源:ofType.spec.ts

示例2: chaiPlugin

/* eslint-env mocha */
import { expect, use } from 'chai';
import { chaiPlugin } from 'brookjs-desalinate';
import Kefir from 'kefir';
import chaiJestSnapshot from 'chai-jest-snapshot';
import sinon from 'sinon';
import { selectWebpackConfig } from '../selectors';
import { State } from '../types';

const { plugin } = chaiPlugin({ Kefir });
use(plugin);
use(chaiJestSnapshot);

describe('BuildCommand#selectors', () => {
  describe('selectWebpackConfig', () => {
    it('should call the modifier when creating webpack config', () => {
      const config = {};
      const modifier = sinon.stub().returns(config);
      const state: State = {
        building: true,
        watch: false,
        env: 'production',
        results: null,
        cwd: '/path/to/cwd',
        rc: {
          webpack: {
            modifier
          } as any
        }
      };
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:30,代码来源:selectors.spec.ts

示例3: chaiPlugin

/* eslint-env mocha */
import { applyMiddleware, createStore } from 'redux';
import chai, { expect } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Kefir from 'kefir';
import configureStore from 'redux-mock-store';
import { chaiPlugin } from 'brookjs-desalinate';
import ofType from '../ofType';
import { observeDelta } from '../observeDelta';

chai.use(sinonChai);
const { plugin, value } = chaiPlugin({ Kefir });
chai.use(plugin);

describe('observeDelta', function() {
  let delta,
    delta$,
    deltaMiddlware,
    reducer,
    initial,
    store,
    actions$,
    state$,
    sub;

  beforeEach(function() {
    delta = sinon.spy(function() {
      return (delta$ = Kefir.pool());
    });
    deltaMiddlware = observeDelta(delta);
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:31,代码来源:observeDelta.spec.ts

示例4: chaiPlugin

/* eslint-env mocha */
// @flow
import { expect, use } from 'chai';
import Kefir from 'kefir';
import { chaiPlugin } from 'brookjs-desalinate';
import view from '../view';

const { plugin, stream, prop, value, send, error, end } = chaiPlugin({ Kefir });
use(plugin);

describe('view', () => {
  it('should be a function', () => {
    expect(view).to.be.a('function');
  });

  it('should take a callback and return a function', () => {
    expect(view(x => x)).to.be.a('function');
  });

  it('should be able to be passed to Observable#thru', () => {
    expect(stream().thru(view(x => x))).to.be.an.observable.stream();
    expect(prop().thru(view(x => x))).to.be.an.observable.property();
  });

  it('should emit result from function callback', () => {
    const a = stream();

    expect(a.thru(view(x => !x))).to.emit([value(true)], () => {
      send(a, [value(false)]);
    });
  });
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:31,代码来源:view.spec.ts


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