Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return a [ngrx-forms] SetErrors action if the register service throws', () => {
const result = {
error: {
errors: { invalid: 'Invalid data' } as Errors,
},
};
const registerAction = AuthActions.register();
const setErrors = new SetErrors(result.error.errors);
actions$ = hot('-a---', { a: registerAction });
const response = cold('-#', {}, result);
service.register = jest.fn(() => response);
const expected = cold('--b', { b: setErrors });
expect(effects.register$).toBeObservable(expected);
});
});
it("should dispatch a showMessageAction", () => {
const message = {
type: MessageType.Success,
content: "Job Created Successfully",
duration: 5000
};
const action = fromActions.submitJobCompleteAction({ job });
const outcome = showMessageAction({ message });
actions = hot("-a", { a: action });
const expected = cold("-b", { b: outcome });
expect(effects.submitJobCompleteMessage$).toBeObservable(expected);
});
});
it("CheckExportStatus should dispatch another CheckExportStatus action if the download isn't ready", () => {
actions = hot('a', {
a: new Actions.CheckExportStatus({ reportId, taskId }),
});
const response = cold('-b', { b: { state: 'newp' } });
const expected = cold(delay + 'c', {
c: new Actions.CheckExportStatus({ reportId, taskId }),
});
service.checkStatus.and.returnValue(response);
expect(effects.checkExportStatus$).toBeObservable(expected);
});
it('should initialize product$', () => {
facade.product$ = hot('ab', { a: null, b: mockProduct });
component.ngOnInit();
const expected = cold('ab', { a: null, b: mockProduct });
expect(component.product$).toBeObservable(expected);
});
) {
routerStateObservable = cold(routerMarbels, {
a: mockRouterState,
});
configurationObservable = cold(configurationMarbels, {
x: configCreate,
y: configCreate2,
});
overviewObservable = cold(overviewMarbels, {
u: configCreate,
v: configCreate2,
});
component.ngOnInit();
expect(component.configuration$).toBeObservable(
cold(expectedMarbels, { u: configCreate, v: configCreate2 })
);
}
it('returns a UserUpsertSuccess, if request is successful ', () => {
const testUser: IUser = {
uid: 'uid',
email: 'email1',
...testNonSensitiveUser
};
const action = new UserUpsertRequest(testUser);
actions$.stream = hot('-a', { a: action });
const completionAction = new UserUpsertSuccess(testUser);
const expected = cold('-b', { b: completionAction });
expect(effects.upsertUsers$).toBeObservable(expected);
});
});
it('should resolve effects from instances', () => {
const sources$ = cold('--a--', { a: new SourceA() });
const expected = cold('--a--', { a });
const output = toActions(sources$);
expect(output).toBeObservable(expected);
});
it('should be able to request a forgot password email', () => {
const action = new UserActions.ForgotPasswordEmailRequest(
'test@test.com'
);
const completion1 = new UserActions.ForgotPasswordEmailRequestSuccess();
const completion2 = new GlobalMessageActions.AddMessage({
text: { key: 'forgottenPassword.passwordResetEmailSent' },
type: GlobalMessageType.MSG_TYPE_CONFIRMATION,
});
actions$ = hot('-a', { a: action });
const expected = cold('-(bc)', { b: completion1, c: completion2 });
expect(effect.requestForgotPasswordEmail$).toBeObservable(expected);
});
});
it("should result in a fetchSamplesCompleteAction and a fetchSamplesCountAction", () => {
const samples = [sample];
const action = fromActions.setTextFilterAction({ text });
const outcome1 = fromActions.fetchSamplesCompleteAction({ samples });
const outcome2 = fromActions.fetchSamplesCountAction();
actions = hot("-a", { a: action });
const response = cold("-a|", { a: samples });
sampleApi.fullquery.and.returnValue(response);
const expected = cold("--(bc)", { b: outcome1, c: outcome2 });
expect(effects.fetchSamples$).toBeObservable(expected);
});
it('returns cartSelector.isCartEmpty', () => {
const expected = cold('(a)', { a: stubIsCartEmpty });
expect(cartWrapperComponent.isCartEmpty$).toBeObservable(expected);
});
});