Skip to content

Commit

Permalink
feat: return this in expectErrors()
Browse files Browse the repository at this point in the history
fix #46
  • Loading branch information
petrzjunior committed Feb 18, 2022
1 parent 7ffe97f commit be89804
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/observer-spy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ describe('ObserverSpy', () => {
expect(observerSpy.receivedError()).toBe(true);
});

it('should know whether it got an "error" notification if "expectErrors" was called', () => {
const observerSpy: ObserverSpy<string> = new ObserverSpy<string>().expectErrors();
const { throwingObservable } = getThrowingObservable();

throwingObservable.subscribe(observerSpy).unsubscribe();

expect(observerSpy.receivedError()).toBe(true);
});

it('should return the error object it received if "expectErrors" is configured', () => {
const observerSpy: ObserverSpy<string> = new ObserverSpy({ expectErrors: true });
const { throwingObservable } = getThrowingObservable();
Expand Down
3 changes: 2 additions & 1 deletion src/observer-spy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ export class ObserverSpy<T> implements Observer<T> {
});
}

expectErrors() {
expectErrors(): this {
this.state.errorIsExpected = true;
return this;
}

getValuesLength(): number {
Expand Down

0 comments on commit be89804

Please sign in to comment.