本文整理汇总了TypeScript中@ngrx/effects/testing.MockStateUpdates类的典型用法代码示例。如果您正苦于以下问题:TypeScript MockStateUpdates类的具体用法?TypeScript MockStateUpdates怎么用?TypeScript MockStateUpdates使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockStateUpdates类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: inject
inject([TagEffectsService, MockStateUpdates], (service: TagEffectsService, updates$: MockStateUpdates) => {
updates$.sendAction({
type: 'REMOVE_TAG',
payload: 1
});
let wasCalled = false;
service.deleteTag$.subscribe(action => {
expect(tagsApi.remove).toHaveBeenCalledWith(1);
wasCalled = true;
});
if (!wasCalled) {
fail('The observable didn\'t emit');
}
}));
开发者ID:isolani-chess,项目名称:web-client,代码行数:14,代码来源:tag-effects.service.spec.ts
示例2: describe
describe('Shop Effect LOAD', () => {
let shop: ShopEffects;
let updates$: MockStateUpdates;
beforeEach(function () {
const injector = ReflectiveInjector.resolveAndCreate([
ShopEffects,
MOCK_EFFECTS_PROVIDERS,
// Mock out other dependencies (like Http) here
]);
shop = injector.get(ShopEffects);
updates$ = injector.get(MockStateUpdates);
});
it('should dispatch products list', (done) => {
updates$.sendAction({ type: fromProducts.REQUEST_PRODUCTS });
shop.load$
.filter(Boolean)
.subscribe(last => {
expect(last).toEqual({ type: fromProducts.RECEIVED_PRODUCTS, payload: jsonProducts });
done();
});
});
it('should checkout products', (done) => {
updates$.sendAction({ type: CHECKOUT_REQUEST, payload: [0, 1] });
shop.checkout$
.filter(Boolean)
.subscribe(last => {
expect(last).toEqual({ type: CHECKOUT_SUCCESS, payload: 0 });
done();
});
});
});
开发者ID:ManuCutillas,项目名称:ngrx-examples,代码行数:39,代码来源:shop.spec.ts
示例3: it
it('should checkout products', (done) => {
updates$.sendAction({ type: CHECKOUT_REQUEST, payload: [0, 1] });
shop.checkout$
.filter(Boolean)
.subscribe(last => {
expect(last).toEqual({ type: CHECKOUT_SUCCESS, payload: 0 });
done();
});
});
开发者ID:ManuCutillas,项目名称:ngrx-examples,代码行数:11,代码来源:shop.spec.ts
注:本文中的@ngrx/effects/testing.MockStateUpdates类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论