@@ -144,12 +144,9 @@ describe('PoolPlus', () => {
144
144
const error = new Error ( 'test error' ) ;
145
145
146
146
before ( ( ) => {
147
- sinon . stub ( pool , 'getConnection' , function ( cb ) {
148
- process . nextTick ( ( ) => cb ( error ) ) ;
149
- } ) ;
150
- sinon . stub ( TableDefinition . prototype , 'genSyncOperations' , function ( cb ) {
151
- process . nextTick ( ( ) => cb ( null , [ { sql : 'pretend sql' , type : - 1 } ] ) ) ;
152
- } ) ;
147
+ sinon . stub ( pool , 'getConnection' ) . yieldsAsync ( error ) ;
148
+ sinon . stub ( TableDefinition . prototype , 'genSyncOperations' )
149
+ . yieldsAsync ( null , [ { sql : 'pretend sql' , type : - 1 } ] ) ;
153
150
} ) ;
154
151
155
152
after ( ( ) => {
@@ -172,9 +169,7 @@ describe('PoolPlus', () => {
172
169
const error = new Error ( 'test error' ) ;
173
170
174
171
before ( ( ) => {
175
- sinon . stub ( TableDefinition . prototype , 'genSyncOperations' , function ( cb ) {
176
- process . nextTick ( ( ) => cb ( error ) ) ;
177
- } ) ;
172
+ sinon . stub ( TableDefinition . prototype , 'genSyncOperations' ) . yieldsAsync ( error ) ;
178
173
} ) ;
179
174
180
175
after ( ( ) => {
@@ -196,13 +191,9 @@ describe('PoolPlus', () => {
196
191
const error = new Error ( 'test error' ) ;
197
192
198
193
before ( ( ) => {
199
- sinon . stub ( Connection . prototype , 'query' , function ( ) {
200
- const cb = arguments . length > 0 && arguments [ arguments . length - 1 ] ;
201
- process . nextTick ( ( ) => cb ( error ) ) ;
202
- } ) ;
203
- sinon . stub ( TableDefinition . prototype , 'genSyncOperations' , function ( cb ) {
204
- process . nextTick ( ( ) => cb ( null , [ { sql : 'pretend sql' , type : - 1 } , { sql : '' , type : 0 } ] ) ) ;
205
- } ) ;
194
+ sinon . stub ( Connection . prototype , 'query' ) . yieldsAsync ( error ) ;
195
+ sinon . stub ( TableDefinition . prototype , 'genSyncOperations' )
196
+ . yieldsAsync ( null , [ { sql : 'pretend sql' , type : - 1 } , { sql : '' , type : 0 } ] ) ;
206
197
} ) ;
207
198
208
199
after ( ( ) => {
@@ -229,7 +220,7 @@ describe('PoolPlus', () => {
229
220
const expectedValues = [ 'solution' ] ;
230
221
function expectedCb ( ) { /* no-op */ }
231
222
232
- sinon . stub ( pool , 'query' , function ( sql , values , cb ) {
223
+ sinon . stub ( pool , 'query' ) . callsFake ( ( sql , values , cb ) => {
233
224
sql . should . equal ( expectedSql ) ;
234
225
values . should . equal ( expectedValues ) ;
235
226
cb . should . equal ( expectedCb ) ;
@@ -425,9 +416,7 @@ describe('PoolPlus', () => {
425
416
const error = new Error ( 'test error' ) ;
426
417
427
418
before ( ( ) => {
428
- sinon . stub ( pool , 'getConnection' , function ( cb ) {
429
- process . nextTick ( ( ) => cb ( error ) ) ;
430
- } ) ;
419
+ sinon . stub ( pool , 'getConnection' ) . yieldsAsync ( error ) ;
431
420
} ) ;
432
421
433
422
after ( ( ) => {
@@ -454,9 +443,7 @@ describe('PoolPlus', () => {
454
443
const error = new Error ( 'test error' ) ;
455
444
456
445
before ( ( ) => {
457
- sinon . stub ( Connection . prototype , 'beginTransaction' , function ( cb ) {
458
- process . nextTick ( ( ) => cb ( error ) ) ;
459
- } ) ;
446
+ sinon . stub ( Connection . prototype , 'beginTransaction' ) . yieldsAsync ( error ) ;
460
447
} ) ;
461
448
462
449
after ( ( ) => {
@@ -483,9 +470,7 @@ describe('PoolPlus', () => {
483
470
const error = new Error ( 'test error' ) ;
484
471
485
472
before ( ( ) => {
486
- sinon . stub ( Connection . prototype , 'commit' , function ( cb ) {
487
- process . nextTick ( ( ) => cb ( error ) ) ;
488
- } ) ;
473
+ sinon . stub ( Connection . prototype , 'commit' ) . yieldsAsync ( error ) ;
489
474
} ) ;
490
475
491
476
after ( ( ) => {
@@ -534,7 +519,7 @@ describe('PoolPlus', () => {
534
519
sinon . stub ( require . cache [ require . resolve ( '../../lib/TableDefinition' ) ] , 'exports' ) ;
535
520
536
521
// Prevent checking for duplicate table definitions
537
- sinon . stub ( Map . prototype , 'has' , ( ) => false ) ;
522
+ sinon . stub ( Map . prototype , 'has' ) . returns ( false ) ;
538
523
539
524
MockPool = require ( '../../lib/PoolPlus' ) ;
540
525
TableDefinitionStub = require ( '../../lib/TableDefinition' ) ;
0 commit comments