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