@@ -442,29 +442,32 @@ describe('Cursor', () => {
442
442
describe ( '#readPref' , ( ) => {
443
443
let spCursor : StubbedInstance < ServiceProviderCursor > ;
444
444
let shellApiCursor ;
445
+ let fromOptionsStub ;
445
446
const value = 'primary' ;
447
+ const tagSet = [ { nodeType : 'ANALYTICS' } ] ;
446
448
447
449
beforeEach ( ( ) => {
448
450
spCursor = stubInterface < ServiceProviderCursor > ( ) ;
449
451
shellApiCursor = new Cursor ( mongo , spCursor ) ;
452
+ fromOptionsStub = sinon . stub ( ) ;
453
+ fromOptionsStub . callsFake ( input => input ) ;
454
+ mongo . _serviceProvider = {
455
+ readPreferenceFromOptions : fromOptionsStub
456
+ } ;
450
457
} ) ;
451
458
452
459
it ( 'fluidly sets the read preference' , ( ) => {
453
460
expect ( shellApiCursor . readPref ( value ) ) . to . equal ( shellApiCursor ) ;
454
461
expect ( spCursor . withReadPreference ) . to . have . been . calledWith ( value ) ;
455
462
} ) ;
456
463
457
- it ( 'throws MongoshUnimplementedError if tagset is passed' , ( ) => {
458
- try {
459
- shellApiCursor . readPref ( value , [ ] ) ;
460
- expect . fail ( 'expected error' ) ;
461
- } catch ( e ) {
462
- expect ( e ) . to . be . instanceOf ( MongoshUnimplementedError ) ;
463
- expect ( e . message ) . to . contain ( 'the tagSet argument is not yet supported.' ) ;
464
- expect ( e . code ) . to . equal ( CommonErrors . NotImplemented ) ;
465
- expect ( e . metadata ?. driverCaused ) . to . equal ( true ) ;
466
- expect ( e . metadata ?. api ) . to . equal ( 'Cursor.readPref#tagSet' ) ;
467
- }
464
+ it ( 'fluidly sets the read preference with tagSet and hedge options' , ( ) => {
465
+ expect ( shellApiCursor . readPref ( value , tagSet , { enabled : true } ) ) . to . equal ( shellApiCursor ) ;
466
+ expect ( spCursor . withReadPreference ) . to . have . been . calledWith ( {
467
+ readPreference : value ,
468
+ readPreferenceTags : tagSet ,
469
+ hedge : { enabled : true }
470
+ } ) ;
468
471
} ) ;
469
472
} ) ;
470
473
0 commit comments