@@ -46,7 +46,9 @@ import {
46
46
SpecQueryFilter ,
47
47
SpecQueryOrderBy ,
48
48
SpecStep ,
49
- SpecWatchFilter
49
+ SpecWatchFilter ,
50
+ SpecWriteAck ,
51
+ SpecWriteFailure
50
52
} from './spec_test_runner' ;
51
53
import { TimerId } from '../../../src/util/async_queue' ;
52
54
@@ -464,7 +466,7 @@ export class SpecBuilder {
464
466
/**
465
467
* Acks a write with a version and optional additional options.
466
468
*
467
- * expectUserCallback defaults to true if options are omitted.
469
+ * expectUserCallback defaults to true if omitted.
468
470
*/
469
471
writeAcks (
470
472
doc : string ,
@@ -474,11 +476,13 @@ export class SpecBuilder {
474
476
this . nextStep ( ) ;
475
477
options = options || { } ;
476
478
477
- this . currentStep = {
478
- writeAck : { version, keepInQueue : ! ! options . keepInQueue }
479
- } ;
479
+ const writeAck : SpecWriteAck = { version } ;
480
+ if ( options . keepInQueue ) {
481
+ writeAck . keepInQueue = true ;
482
+ }
483
+ this . currentStep = { writeAck } ;
480
484
481
- if ( options . expectUserCallback ) {
485
+ if ( options . expectUserCallback !== false ) {
482
486
return this . expectUserCallbacks ( { acknowledged : [ doc ] } ) ;
483
487
} else {
484
488
return this ;
@@ -488,7 +492,7 @@ export class SpecBuilder {
488
492
/**
489
493
* Fails a write with an error and optional additional options.
490
494
*
491
- * expectUserCallback defaults to true if options are omitted.
495
+ * expectUserCallback defaults to true if omitted.
492
496
*/
493
497
failWrite (
494
498
doc : string ,
@@ -506,9 +510,13 @@ export class SpecBuilder {
506
510
? options . keepInQueue
507
511
: ! isPermanentFailure ;
508
512
509
- this . currentStep = { failWrite : { error, keepInQueue } } ;
513
+ const failWrite : SpecWriteFailure = { error } ;
514
+ if ( keepInQueue ) {
515
+ failWrite . keepInQueue = true ;
516
+ }
517
+ this . currentStep = { failWrite } ;
510
518
511
- if ( options . expectUserCallback ) {
519
+ if ( options . expectUserCallback !== false ) {
512
520
return this . expectUserCallbacks ( { rejected : [ doc ] } ) ;
513
521
} else {
514
522
return this ;
0 commit comments