本文整理匯總了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();
});
});