Skip to content

Commit

Permalink
more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Oct 4, 2023
1 parent 01a82d3 commit 8c5cb7d
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/testing/internal/__tests__/ObservableStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@ import { Observable } from "../../../utilities";
import { ObservableStream } from "../ObservableStream";

it("allows to step through an observable until completion", async () => {
const taker = new ObservableStream(
const stream = new ObservableStream(
new Observable<number>((observer) => {
observer.next(1);
observer.next(2);
observer.next(3);
observer.complete();
})
);
await expect(taker.takeNext()).resolves.toBe(1);
await expect(taker.takeNext()).resolves.toBe(2);
await expect(taker.takeNext()).resolves.toBe(3);
await expect(taker.takeComplete()).resolves.toBeUndefined();
await expect(stream.takeNext()).resolves.toBe(1);
await expect(stream.takeNext()).resolves.toBe(2);
await expect(stream.takeNext()).resolves.toBe(3);
await expect(stream.takeComplete()).resolves.toBeUndefined();
});

it("allows to step through an observable until error", async () => {
const taker = new ObservableStream(
const stream = new ObservableStream(
new Observable<number>((observer) => {
observer.next(1);
observer.next(2);
observer.next(3);
observer.error(new Error("expected"));
})
);
await expect(taker.takeNext()).resolves.toBe(1);
await expect(taker.takeNext()).resolves.toBe(2);
await expect(taker.takeNext()).resolves.toBe(3);
await expect(taker.takeError()).resolves.toEqual(expect.any(Error));
await expect(stream.takeNext()).resolves.toBe(1);
await expect(stream.takeNext()).resolves.toBe(2);
await expect(stream.takeNext()).resolves.toBe(3);
await expect(stream.takeError()).resolves.toEqual(expect.any(Error));
});

it("will time out if no more value is omitted", async () => {
const taker = new ObservableStream(
const stream = new ObservableStream(
new Observable<number>((observer) => {
observer.next(1);
observer.next(2);
})
);
await expect(taker.takeNext()).resolves.toBe(1);
await expect(taker.takeNext()).resolves.toBe(2);
await expect(taker.takeNext()).rejects.toEqual(expect.any(Error));
await expect(stream.takeNext()).resolves.toBe(1);
await expect(stream.takeNext()).resolves.toBe(2);
await expect(stream.takeNext()).rejects.toEqual(expect.any(Error));
});

it.each([
Expand All @@ -51,35 +51,35 @@ it.each([
["takeComplete", "next"],
["takeComplete", "error"],
])("errors when %s receives %s instead", async (expected, gotten) => {
const taker = new ObservableStream(
const stream = new ObservableStream(
new Observable<number>((observer) => {
observer.next(1);
observer.next(2);
// @ts-ignore
observer[gotten](3);
})
);
await expect(taker.takeNext()).resolves.toBe(1);
await expect(taker.takeNext()).resolves.toBe(2);
await expect(stream.takeNext()).resolves.toBe(1);
await expect(stream.takeNext()).resolves.toBe(2);
// @ts-ignore
await expect(taker[expected]()).rejects.toEqual(expect.any(Error));
await expect(stream[expected]()).rejects.toEqual(expect.any(Error));
});

it.each([
["takeNext", "next"],
["takeError", "error"],
["takeComplete", "complete"],
])("succeeds when %s, receives %s", async (expected, gotten) => {
const taker = new ObservableStream(
const stream = new ObservableStream(
new Observable<number>((observer) => {
observer.next(1);
observer.next(2);
// @ts-ignore
observer[gotten](3);
})
);
await expect(taker.takeNext()).resolves.toBe(1);
await expect(taker.takeNext()).resolves.toBe(2);
await expect(stream.takeNext()).resolves.toBe(1);
await expect(stream.takeNext()).resolves.toBe(2);
// @ts-ignore this should just not throw
await taker[expected]();
await stream[expected]();
});

0 comments on commit 8c5cb7d

Please sign in to comment.