本文整理汇总了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' })],
示例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
}
};
示例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);
示例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)]);
});
});