11import { hasNext , noNext , delayValue } from '../asynciterablehelpers' ;
22import { takeUntil } from 'ix/asynciterable/operators' ;
33import { as } from 'ix/asynciterable' ;
4+ import { AsyncSink } from 'ix/asynciterable' ;
45
56test ( 'AsyncIterable#takeUntil hits' , async ( ) => {
6- const xs = async function * ( ) {
7+ const xs = async function * ( ) {
78 yield await delayValue ( 1 , 100 ) ;
89 yield await delayValue ( 2 , 300 ) ;
910 yield await delayValue ( 3 , 1200 ) ;
@@ -17,7 +18,7 @@ test('AsyncIterable#takeUntil hits', async () => {
1718} ) ;
1819
1920test ( 'AsyncIterable#takeUntil misses' , async ( ) => {
20- const xs = async function * ( ) {
21+ const xs = async function * ( ) {
2122 yield await delayValue ( 1 , 100 ) ;
2223 yield await delayValue ( 2 , 300 ) ;
2324 yield await delayValue ( 3 , 600 ) ;
@@ -30,3 +31,11 @@ test('AsyncIterable#takeUntil misses', async () => {
3031 await hasNext ( it , 3 ) ;
3132 await noNext ( it ) ;
3233} ) ;
34+
35+ test ( 'AsyncIterable#takeUntil completes immediately' , async ( ) => {
36+ const sink = new AsyncSink < void > ( ) ;
37+ const ys = as ( sink ) . pipe ( takeUntil ( ( ) => Promise . resolve ( ) ) ) ;
38+
39+ const it = ys [ Symbol . asyncIterator ] ( ) ;
40+ await noNext ( it ) ;
41+ } ) ;
0 commit comments