@@ -653,7 +653,7 @@ describe('store', function () {
653653 beforeEach ( function ( ) {
654654 sinon
655655 . stub ( dataService , 'findOneAndUpdate' )
656- . yields ( { message : 'error happened' } ) ;
656+ . throws ( { message : 'error happened' } ) ;
657657 } ) ;
658658
659659 it ( 'sets the error for the document' , function ( done ) {
@@ -676,7 +676,7 @@ describe('store', function () {
676676 hadronDoc . elements . at ( 1 ) . rename ( 'new name' ) ;
677677 sinon
678678 . stub ( dataService , 'findOneAndUpdate' )
679- . yields ( { message : 'error happened' } ) ;
679+ . throws ( { message : 'error happened' } ) ;
680680 } ) ;
681681
682682 it ( 'sets the error for the document' , function ( done ) {
@@ -695,7 +695,7 @@ describe('store', function () {
695695
696696 beforeEach ( function ( ) {
697697 hadronDoc . elements . at ( 1 ) . rename ( 'new name' ) ;
698- sinon . stub ( dataService , 'findOneAndUpdate' ) . yields ( null , null ) ;
698+ sinon . stub ( dataService , 'findOneAndUpdate' ) . resolves ( null ) ;
699699 } ) ;
700700
701701 it ( 'sets the update blocked for the document' , function ( done ) {
@@ -714,7 +714,7 @@ describe('store', function () {
714714
715715 beforeEach ( function ( ) {
716716 hadronDoc . get ( 'name' ) . edit ( 'Desert Sand' ) ;
717- stub = sinon . stub ( dataService , 'findOneAndUpdate' ) . yields ( null , { } ) ;
717+ stub = sinon . stub ( dataService , 'findOneAndUpdate' ) . resolves ( { } ) ;
718718 } ) ;
719719
720720 it ( 'has the original value for the edited value in the query' , async function ( ) {
@@ -742,7 +742,7 @@ describe('store', function () {
742742 beforeEach ( function ( ) {
743743 store . state . shardKeys = { yes : 1 } ;
744744 hadronDoc . get ( 'name' ) . edit ( 'Desert Sand' ) ;
745- stub = sinon . stub ( dataService , 'findOneAndUpdate' ) . yields ( null , { } ) ;
745+ stub = sinon . stub ( dataService , 'findOneAndUpdate' ) . resolves ( { } ) ;
746746 } ) ;
747747
748748 afterEach ( function ( ) {
@@ -797,10 +797,10 @@ describe('store', function () {
797797 hadronDoc . get ( 'name' ) . edit ( 'Desert Sand' ) ;
798798 findOneAndReplaceStub = sinon
799799 . stub ( dataService , 'findOneAndReplace' )
800- . yields ( null , { } ) ;
800+ . resolves ( { } ) ;
801801 findOneAndUpdateStub = sinon
802802 . stub ( dataService , 'findOneAndUpdate' )
803- . yields ( null , { } ) ;
803+ . resolves ( { } ) ;
804804 isUpdateAllowedStub = sinon . stub ( ) . resolves ( false ) ;
805805 sinon . stub ( dataService , 'getCSFLEMode' ) . returns ( 'enabled' ) ;
806806 sinon
@@ -869,7 +869,7 @@ describe('store', function () {
869869 beforeEach ( function ( ) {
870870 sinon
871871 . stub ( dataService , 'findOneAndReplace' )
872- . yields ( { message : 'error happened' } ) ;
872+ . rejects ( { message : 'error happened' } ) ;
873873 } ) ;
874874
875875 it ( 'sets the error for the document' , function ( done ) {
@@ -889,7 +889,7 @@ describe('store', function () {
889889
890890 beforeEach ( function ( ) {
891891 hadronDoc . get ( 'name' ) . edit ( 'Desert Sand' ) ;
892- stub = sinon . stub ( dataService , 'findOneAndReplace' ) . yields ( null , { } ) ;
892+ stub = sinon . stub ( dataService , 'findOneAndReplace' ) . resolves ( { } ) ;
893893 } ) ;
894894
895895 it ( 'has the original value for the edited value in the query' , async function ( ) {
@@ -912,7 +912,7 @@ describe('store', function () {
912912 beforeEach ( function ( ) {
913913 store . state . shardKeys = { yes : 1 } ;
914914 hadronDoc . get ( 'name' ) . edit ( 'Desert Sand' ) ;
915- stub = sinon . stub ( dataService , 'findOneAndReplace' ) . yields ( null , { } ) ;
915+ stub = sinon . stub ( dataService , 'findOneAndReplace' ) . resolves ( { } ) ;
916916 } ) ;
917917
918918 afterEach ( function ( ) {
@@ -948,10 +948,10 @@ describe('store', function () {
948948 hadronDoc . get ( 'name' ) . edit ( 'Desert Sand' ) ;
949949 findOneAndReplaceStub = sinon
950950 . stub ( dataService , 'findOneAndReplace' )
951- . yields ( null , { } ) ;
951+ . resolves ( { } ) ;
952952 findOneAndUpdateStub = sinon
953953 . stub ( dataService , 'findOneAndUpdate' )
954- . yields ( null , { } ) ;
954+ . resolves ( { } ) ;
955955 isUpdateAllowedStub = sinon . stub ( ) . resolves ( false ) ;
956956 sinon . stub ( dataService , 'getCSFLEMode' ) . returns ( 'enabled' ) ;
957957 sinon
@@ -2066,8 +2066,8 @@ describe('store', function () {
20662066
20672067 it ( 'does the original findAndModify operation and nothing more if it succeeds' , async function ( ) {
20682068 const document = { _id : 1234 } ;
2069- const stub = sinon . stub ( ) . callsFake ( ( ds , ns , opts , cb ) => {
2070- cb ( undefined , document ) ;
2069+ const stub = sinon . stub ( ) . callsFake ( ( ) => {
2070+ return [ undefined , document ] ;
20712071 } ) ;
20722072 const [ error , d ] = await findAndModifyWithFLEFallback (
20732073 dataServiceStub ,
@@ -2087,8 +2087,8 @@ describe('store', function () {
20872087
20882088 it ( 'does the original findAndModify operation and nothing more if it fails with a non-FLE error' , async function ( ) {
20892089 const err = new Error ( 'failed' ) ;
2090- const stub = sinon . stub ( ) . callsFake ( ( ds , ns , opts , cb ) => {
2091- cb ( err ) ;
2090+ const stub = sinon . stub ( ) . callsFake ( ( ) => {
2091+ return [ err ] ;
20922092 } ) ;
20932093 const [ error , d ] = await findAndModifyWithFLEFallback (
20942094 dataServiceStub ,
@@ -2110,11 +2110,11 @@ describe('store', function () {
21102110 const document = { _id : 1234 } ;
21112111 const err = Object . assign ( new Error ( 'failed' ) , { code : 6371402 } ) ;
21122112 const stub = sinon . stub ( ) ;
2113- stub . onFirstCall ( ) . callsFake ( ( ds , ns , opts , cb ) => {
2114- cb ( err ) ;
2113+ stub . onFirstCall ( ) . callsFake ( ( ) => {
2114+ return [ err ] ;
21152115 } ) ;
2116- stub . onSecondCall ( ) . callsFake ( ( ds , ns , opts , cb ) => {
2117- cb ( undefined , document ) ;
2116+ stub . onSecondCall ( ) . callsFake ( ( ) => {
2117+ return [ undefined , document ] ;
21182118 } ) ;
21192119 const [ error , d ] = await findAndModifyWithFLEFallback (
21202120 dataServiceStub ,
@@ -2150,11 +2150,11 @@ describe('store', function () {
21502150 const document = { _id : 1234 } ;
21512151 const err = Object . assign ( new Error ( 'failed' ) , { code : 6371402 } ) ;
21522152 const stub = sinon . stub ( ) ;
2153- stub . onFirstCall ( ) . callsFake ( ( ds , ns , opts , cb ) => {
2154- cb ( err ) ;
2153+ stub . onFirstCall ( ) . callsFake ( ( ) => {
2154+ return [ err ] ;
21552155 } ) ;
2156- stub . onSecondCall ( ) . callsFake ( ( ds , ns , opts , cb ) => {
2157- cb ( undefined , document ) ;
2156+ stub . onSecondCall ( ) . callsFake ( ( ) => {
2157+ return [ undefined , document ] ;
21582158 } ) ;
21592159 const [ error , d ] = await findAndModifyWithFLEFallback (
21602160 dataServiceStub ,
0 commit comments