@@ -3,8 +3,6 @@ import { describe, it } from 'mocha';
33
44import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js' ;
55
6- import { promiseWithResolvers } from '../../jsutils/promiseWithResolvers.js' ;
7-
86import { Queue } from '../Queue.js' ;
97
108describe ( 'Queue' , ( ) => {
@@ -91,6 +89,17 @@ describe('Queue', () => {
9189 } ) ;
9290
9391 it ( 'should allow the executor to indicate completion' , async ( ) => {
92+ const queue = new Queue < number > ( ( push , stop ) => {
93+ push ( 1 ) ;
94+ stop ( ) ;
95+ } ) ;
96+
97+ const sub = queue . subscribe ( ( batch ) => Array . from ( batch ) ) ;
98+ expect ( await sub . next ( ) ) . to . deep . equal ( { done : false , value : [ 1 ] } ) ;
99+ expect ( await sub . next ( ) ) . to . deep . equal ( { done : true , value : undefined } ) ;
100+ } ) ;
101+
102+ it ( 'should allow the executor to indicate completion prior to any push calls' , async ( ) => {
94103 const queue = new Queue < number > ( ( push , stop ) => {
95104 stop ( ) ;
96105 push ( 1 ) ; // should be ignored
@@ -101,10 +110,8 @@ describe('Queue', () => {
101110 } ) ;
102111
103112 it ( 'should allow a consumer to abort a pending call to next' , async ( ) => {
104- const queue = new Queue < number > ( async ( ) => {
105- const { promise } = promiseWithResolvers ( ) ;
106- // wait forever
107- await promise ;
113+ const queue = new Queue < number > ( ( ) => {
114+ // no pushes
108115 } ) ;
109116
110117 const sub = queue . subscribe ( ( batch ) => batch ) ;
0 commit comments