Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Dec 23, 2024
1 parent 503296c commit dd667e8
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/examples/pipe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ it("Pipe Usage Example Test", () => {
}
});

it("Chain pipe Usage Example Test", () => {
it("Chained Pipe Usage Example Test", () => {
const pipe = createPipe(set.distinct<number>)
.add((input) => single.map(input, (x) => x**2))
.add((input) => single.filter(input, (x) => x < 10))
Expand All @@ -64,7 +64,7 @@ it("Chain pipe Usage Example Test", () => {
}
});

it("Another chain pipe Usage Example Test", () => {
it("Another Chain Pipe Usage Example Test", () => {
const pipe = createPipe()
.add(set.distinct<number>)
.add((input) => single.map(input, (x) => x**2))
Expand Down Expand Up @@ -161,6 +161,28 @@ it("Async Pipe Usage Example Without Type Annotations Test", async () => {
}
});

it("Chained Async Pipe Usage Example Test", async () => {
const asyncPipe = createPipe()
.add(set.distinctAsync<number>)
.add((input) => single.mapAsync(input, async (x) => x**2))
.add((input) => single.filterAsync(input, (x) => x < 10))
.add(reduce.toSumAsync);

{
const input = createAsyncIterableFixture([1, 1, 2, 2, 3, 4, 5]);
const result = await asyncPipe(input);

expect(result).toBe(14);
}

{
const input = createAsyncIterableFixture([1, 1, 1, 2, 2, 2]);
const result = await asyncPipe(input);

expect(result).toBe(5);
}
});

it("Non-iterables Test", () => {
const pipe = createPipe(
(x: number) => x+1,
Expand Down

0 comments on commit dd667e8

Please sign in to comment.