-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(src/asynciterable/operators/timeout.ts): ensure AsyncIterable tim…
…eout operator passes its values Typo introduced by linting in a refactor prevented AsyncIterable from passing on its values. fix #325
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { hasNext, noNext, delayValue } from '../asynciterablehelpers'; | ||
import { timeout } from 'ix/asynciterable/operators'; | ||
import { as } from 'ix/asynciterable'; | ||
import { TimeoutError } from 'ix/asynciterable/operators/timeout'; | ||
|
||
test('AsyncIterable#timeout drops none', async () => { | ||
const xs = async function* () { | ||
yield await delayValue(1, 50); | ||
yield await delayValue(2, 50); | ||
yield await delayValue(3, 50); | ||
}; | ||
const ys = as(xs()).pipe(timeout(100)); | ||
|
||
const it = ys[Symbol.asyncIterator](); | ||
await hasNext(it, 1); | ||
await hasNext(it, 2); | ||
await hasNext(it, 3); | ||
await noNext(it); | ||
}); | ||
|
||
test('AsyncIterable#timeout throws when delayed', async () => { | ||
const xs = async function* () { | ||
yield await delayValue(1, 50); | ||
yield await delayValue(2, 200); | ||
}; | ||
const ys = as(xs()).pipe(timeout(100)); | ||
|
||
const it = ys[Symbol.asyncIterator](); | ||
await hasNext(it, 1); | ||
try { | ||
await it.next(); | ||
} catch (e) { | ||
expect(e).toBeInstanceOf(TimeoutError); | ||
} | ||
await noNext(it); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters