sequelize-mock-v5 1.2.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,9 +14,9 @@ var UtilsMock = {
14
14
 
15
15
  var QueryInterfaceMock = function () { this._args = arguments; };
16
16
  QueryInterfaceMock.prototype = {
17
- $queueResult: function () {},
18
- $queueFailure: function () {},
19
- $clearQueue: function () {},
17
+ $queueResult: function () { },
18
+ $queueFailure: function () { },
19
+ $clearQueue: function () { },
20
20
  $query: function (q) { return q; },
21
21
  };
22
22
 
@@ -27,7 +27,7 @@ var Model = proxyquire('../src/model', {
27
27
  });
28
28
 
29
29
  describe('Model', function () {
30
-
30
+
31
31
  describe('__constructor', function () {
32
32
  var pluralize;
33
33
  beforeEach(function () {
@@ -36,21 +36,21 @@ describe('Model', function () {
36
36
  afterEach(function () {
37
37
  UtilsMock.pluralize = pluralize;
38
38
  });
39
-
39
+
40
40
  it('should assign a name to a model', function () {
41
41
  var mdl = new Model('foo');
42
42
  mdl.name.should.equal('foo');
43
43
  });
44
-
44
+
45
45
  it('should accept an object of default values', function () {
46
46
  var mdl = new Model('baz', {
47
47
  'foo': 'bar',
48
48
  });
49
-
49
+
50
50
  mdl.name.should.equal('baz');
51
51
  mdl._defaults.should.have.property('foo').which.is.exactly('bar');
52
52
  });
53
-
53
+
54
54
  it('should accept default object as first argument', function () {
55
55
  var mdl = new Model({
56
56
  'foo': 'bar',
@@ -58,14 +58,14 @@ describe('Model', function () {
58
58
  mdl.name.should.equal('');
59
59
  mdl._defaults.should.have.property('foo').which.is.exactly('bar');
60
60
  });
61
-
61
+
62
62
  it('should have callable Instance property', function () {
63
63
  var mdl = new Model('foo'),
64
64
  inst = new mdl.Instance('bar');
65
65
  inst.should.be.Object();
66
66
  inst._args[0].should.equal('bar');
67
67
  });
68
-
68
+
69
69
  it('should assign instanceMethods functions to Instance prototype', function () {
70
70
  var fooFn = function () { return 'bar'; },
71
71
  mdl = new Model('baz', {}, {
@@ -73,10 +73,10 @@ describe('Model', function () {
73
73
  foo: fooFn,
74
74
  },
75
75
  });
76
-
76
+
77
77
  mdl.Instance.prototype.should.have.property('foo').which.is.exactly(fooFn);
78
78
  });
79
-
79
+
80
80
  it('should have a default set of options assigned', function () {
81
81
  var mdl = new Model('foo');
82
82
  mdl.options.timestamps.should.be.true();
@@ -87,11 +87,11 @@ describe('Model', function () {
87
87
  mdl.options.createdDefault.should.be.true();
88
88
  mdl.options.autoQueryFallback.should.be.true();
89
89
  });
90
-
90
+
91
91
  it('should inherit options from a passed in sequelize object', function () {
92
92
  var mdl = new Model('foo', {}, {
93
93
  sequelize: {
94
- getQueryInterface: function () {},
94
+ getQueryInterface: function () { },
95
95
  options: {
96
96
  autoQueryFallback: false,
97
97
  stopPropagation: true,
@@ -105,14 +105,14 @@ describe('Model', function () {
105
105
  mdl.options.fallbackFn.should.equal('foo');
106
106
  mdl.options.should.not.have.property('bar');
107
107
  });
108
-
108
+
109
109
  it('should save options from passed in object object', function () {
110
110
  var mdl = new Model('foo', {}, {
111
111
  foo: 'bar'
112
112
  });
113
113
  mdl.options.should.have.property('foo').which.is.exactly('bar');
114
114
  });
115
-
115
+
116
116
  it('should save table name if passed in from options', function () {
117
117
  var mdl = new Model('foo', {}, {
118
118
  tableName: 'bar',
@@ -120,7 +120,7 @@ describe('Model', function () {
120
120
  mdl.name.should.equal('foo');
121
121
  mdl.tableName.should.equal('bar');
122
122
  });
123
-
123
+
124
124
  it('should use a "pluralized" table name if no table name is provided', function () {
125
125
  UtilsMock.pluralize = function () {
126
126
  return 'bar';
@@ -129,7 +129,7 @@ describe('Model', function () {
129
129
  mdl.name.should.equal('foo');
130
130
  mdl.tableName.should.equal('bar');
131
131
  });
132
-
132
+
133
133
  it('should not use a "pluralized" table name if options indicate to freeze table name', function () {
134
134
  UtilsMock.pluralize = function () {
135
135
  return 'bar';
@@ -140,10 +140,10 @@ describe('Model', function () {
140
140
  mdl.name.should.equal('foo');
141
141
  mdl.tableName.should.equal('foo');
142
142
  });
143
-
143
+
144
144
  it('should return an object with the proper API functions', function () {
145
145
  var mdl = new Model('foo');
146
-
146
+
147
147
  // Test API functions
148
148
  mdl.should.have.property('$queryInterface').which.is.an.Object();
149
149
  mdl.should.have.property('$queueResult').which.is.a.Function();
@@ -152,9 +152,9 @@ describe('Model', function () {
152
152
  mdl.should.have.property('$clearQueue').which.is.a.Function();
153
153
  mdl.should.have.property('$queueClear').which.is.a.Function();
154
154
  mdl.should.have.property('$query').which.is.a.Function();
155
-
155
+
156
156
  // Not yet supported functions are commented out
157
-
157
+
158
158
  // mdl.should.have.property('removeAttributes').which.is.a.Function();
159
159
  mdl.should.have.property('sync').which.is.a.Function();
160
160
  // mdl.should.have.property('drop').which.is.a.Function();
@@ -188,138 +188,167 @@ describe('Model', function () {
188
188
  mdl.should.have.property('update').which.is.a.Function();
189
189
  // mdl.should.have.property('describe').which.is.a.Function();
190
190
  });
191
+
192
+ it('should store the model definition for access', function () {
193
+ var modelDef = {
194
+ 'name': 'VARCHAR(255)',
195
+ 'email': 'VARCHAR(255)',
196
+ 'age': 'INTEGER',
197
+ };
198
+ var mdl = new Model('User', modelDef);
199
+
200
+ mdl.should.have.property('modelDefinition').which.is.an.Object();
201
+ mdl.modelDefinition.should.equal(modelDef);
202
+ mdl.modelDefinition.should.have.property('name').which.is.exactly('VARCHAR(255)');
203
+ mdl.modelDefinition.should.have.property('email').which.is.exactly('VARCHAR(255)');
204
+ mdl.modelDefinition.should.have.property('age').which.is.exactly('INTEGER');
205
+ });
206
+
207
+ it('should have modelDefinition accessible through instances', function () {
208
+ var modelDef = {
209
+ 'title': 'VARCHAR(255)',
210
+ 'content': 'TEXT',
211
+ };
212
+ var mdl = new Model('Post', modelDef);
213
+ var instance = mdl.build();
214
+
215
+ instance.Model.should.have.property('modelDefinition').which.is.an.Object();
216
+ instance.Model.modelDefinition.should.equal(modelDef);
217
+ instance.Model.modelDefinition.should.have.property('title').which.is.exactly('VARCHAR(255)');
218
+ instance.Model.modelDefinition.should.have.property('content').which.is.exactly('TEXT');
219
+ });
191
220
  });
192
-
221
+
193
222
  describe('#scope', function () {
194
223
  var mdl;
195
224
  beforeEach(function () {
196
225
  mdl = new Model('foo');
197
226
  });
198
-
227
+
199
228
  it('should return a mock Model object', function () {
200
229
  mdl.scope().should.be.instanceOf(Model);
201
230
  });
202
231
  });
203
-
232
+
204
233
  describe('#sync', function () {
205
234
  var mdl;
206
235
  beforeEach(function () {
207
236
  mdl = new Model('foo');
208
237
  });
209
-
238
+
210
239
  it('should return a promise', function () {
211
240
  mdl.sync().should.be.instanceOf(Promise);
212
241
  });
213
242
  });
214
-
243
+
215
244
  describe('#drop', function () {
216
245
  var mdl;
217
246
  beforeEach(function () {
218
247
  mdl = new Model('foo');
219
248
  });
220
-
249
+
221
250
  it('should return a promise', function () {
222
251
  mdl.drop().should.be.instanceOf(Promise);
223
252
  });
224
253
  });
225
-
254
+
226
255
  describe('#build', function () {
227
256
  var mdl;
228
257
  beforeEach(function () {
229
258
  mdl = new Model('foo');
230
259
  });
231
-
260
+
232
261
  it('should pass along the default values and the override values to Instance in a combined object', function () {
233
262
  mdl._defaults = {
234
263
  'foo': 'bar'
235
264
  };
236
265
  var vals = {
237
- 'baz' : 'bin'
266
+ 'baz': 'bin'
238
267
  };
239
-
268
+
240
269
  var inst = mdl.build(vals);
241
270
  var passed = inst._args[0];
242
271
  passed.should.have.property('foo').which.is.exactly('bar');
243
272
  passed.should.have.property('baz').which.is.exactly('bin');
244
273
  });
245
-
274
+
246
275
  it('should build Instance with Instance.prototype functions', function () {
247
- mdl.Instance.prototype.bar = function () {};
248
-
276
+ mdl.Instance.prototype.bar = function () { };
277
+
249
278
  var inst = mdl.build();
250
279
  inst.should.be.instanceOf(InstanceMock);
251
280
  inst.should.have.property('bar').which.is.exactly(mdl.Instance.prototype.bar);
252
281
  });
253
282
  });
254
-
283
+
255
284
  describe('#create', function () {
256
285
  var mdl;
257
286
  beforeEach(function () {
258
287
  mdl = new Model('foo');
259
288
  });
260
-
289
+
261
290
  it('should create Instance with Instance.prototype functions', async function () {
262
291
  var vals = {
263
- 'baz' : 'bin'
292
+ 'baz': 'bin'
264
293
  };
265
-
294
+
266
295
  let query = await mdl.create(vals);
267
296
  let inst = await query.fallbackFn();
268
297
  inst.should.be.instanceOf(InstanceMock);
269
298
  inst._args[0].should.have.property('baz').which.is.exactly('bin');
270
-
299
+
271
300
  });
272
301
  });
273
-
302
+
274
303
  describe('#update', function () {
275
304
  var mdl;
276
305
  beforeEach(function () {
277
306
  mdl = new Model('foo');
278
307
  });
279
-
308
+
280
309
  it('should pass back default of 1 row updated', async function () {
281
310
  var vals = {
282
- 'baz' : 'bin'
311
+ 'baz': 'bin'
283
312
  };
284
313
  let res = await mdl.update(vals);
285
314
  let [number, rows] = await res.fallbackFn()
286
315
  number.should.equal(1);
287
316
  });
288
-
317
+
289
318
  it('should pass back row updated when returning option is included', async function () {
290
319
  var vals = {
291
- 'baz' : 'bin'
320
+ 'baz': 'bin'
292
321
  };
293
-
294
- let res = await mdl.update(vals, {returning: true});
322
+
323
+ let res = await mdl.update(vals, { returning: true });
295
324
  let [number, rows] = await res.fallbackFn()
296
325
  rows.should.be.Array();
297
326
  rows[0]._args[0].should.have.property('baz').which.is.exactly('bin');
298
-
327
+
299
328
  });
300
329
 
301
330
  it('should not pass back row updated when returning option is set to false', async function () {
302
331
  var vals = {
303
- 'baz' : 'bin'
332
+ 'baz': 'bin'
304
333
  };
305
-
306
- let res = await mdl.update(vals, {returning: false});
334
+
335
+ let res = await mdl.update(vals, { returning: false });
307
336
  let [number, rows] = await res.fallbackFn()
308
337
  number.should.be.equal(1);
309
338
  should.not.exist(rows);
310
339
  });
311
-
312
-
340
+
341
+
313
342
  it('should not pass along a fallback function if auto fallback is turned off', function () {
314
343
  mdl.options.autoQueryFallback = false;
315
344
  should.not.exist(mdl.update().fallbackFn);
316
345
  });
317
-
318
- it('should pass query info to the QueryInterface instance', function(done) {
346
+
347
+ it('should pass query info to the QueryInterface instance', function (done) {
319
348
  var vals = {};
320
349
  var opts = {};
321
-
322
- mdl.$query = function(options) {
350
+
351
+ mdl.$query = function (options) {
323
352
  options.query.should.equal('update');
324
353
  options.queryOptions.length.should.equal(2);
325
354
  options.queryOptions[0].should.equal(vals);
@@ -329,45 +358,45 @@ describe('Model', function () {
329
358
  mdl.update(vals, opts);
330
359
  });
331
360
  });
332
-
361
+
333
362
  describe('#findOne', function () {
334
363
  var mdl;
335
364
  beforeEach(function () {
336
365
  mdl = new Model('foo');
337
366
  });
338
-
339
- it('should find a row with no options given', async function() {
340
- let res = await mdl.findOne()
367
+
368
+ it('should find a row with no options given', async function () {
369
+ let res = await mdl.findOne()
341
370
  let inst = await res.fallbackFn()
342
371
  should.exist(inst)
343
372
  inst.should.be.instanceOf(InstanceMock);
344
373
  });
345
-
374
+
346
375
  it('should find a row with the values from the `where` query', async function () {
347
376
  var options = {
348
377
  where: {
349
378
  'foo': 'bar',
350
379
  },
351
380
  };
352
-
381
+
353
382
  let res = await mdl.findOne(options)
354
383
  let inst = await res.fallbackFn()
355
384
  inst._args[0].should.have.property('foo').which.is.exactly('bar');
356
385
  });
357
-
386
+
358
387
  it('should not pass along a fallback function if auto fallback is turned off', function () {
359
388
  mdl.options.autoQueryFallback = false;
360
389
  should.not.exist(mdl.findOne().fallbackFn);
361
390
  });
362
-
363
- it('should pass query info to the QueryInterface instance', function(done) {
391
+
392
+ it('should pass query info to the QueryInterface instance', function (done) {
364
393
  var queryOptions = {
365
394
  where: {
366
395
  'foo': 'bar',
367
396
  },
368
397
  };
369
-
370
- mdl.$query = function(options) {
398
+
399
+ mdl.$query = function (options) {
371
400
  options.query.should.equal('findOne');
372
401
  options.queryOptions.length.should.equal(1);
373
402
  options.queryOptions[0].should.equal(queryOptions);
@@ -376,26 +405,26 @@ describe('Model', function () {
376
405
  mdl.findOne(queryOptions);
377
406
  });
378
407
  });
379
-
408
+
380
409
  describe('#findById', function () {
381
410
  var mdl;
382
411
  beforeEach(function () {
383
412
  mdl = new Model('foo');
384
413
  });
385
-
386
- it('should find a row with the given id', async function() {
414
+
415
+ it('should find a row with the given id', async function () {
387
416
  let res = await mdl.findById(1234);
388
417
  let inst = await res.fallbackFn();
389
418
  inst._args[0].id.should.equal(1234);
390
419
  });
391
-
420
+
392
421
  it('should not pass along a fallback function if auto fallback is turned off', function () {
393
422
  mdl.options.autoQueryFallback = false;
394
423
  should.not.exist(mdl.findById().fallbackFn);
395
424
  });
396
-
397
- it('should pass query info to the QueryInterface instance', function(done) {
398
- mdl.$query = function(options) {
425
+
426
+ it('should pass query info to the QueryInterface instance', function (done) {
427
+ mdl.$query = function (options) {
399
428
  options.query.should.equal('findById');
400
429
  options.queryOptions.length.should.equal(1);
401
430
  options.queryOptions[0].should.equal(123);
@@ -404,30 +433,30 @@ describe('Model', function () {
404
433
  mdl.findById(123);
405
434
  });
406
435
  });
407
-
436
+
408
437
  describe('#<sum/min/max>', function () {
409
438
  var mdl;
410
439
  beforeEach(function () {
411
440
  mdl = new Model('foo');
412
441
  });
413
-
442
+
414
443
  it('should return the default value for the field', async function () {
415
444
  mdl._defaults.foo = 1234;
416
-
445
+
417
446
  let res = await mdl.sum('foo')
418
447
  let count = await res.fallbackFn()
419
448
  count.should.equal(1234);
420
449
  });
421
-
450
+
422
451
  it('should not pass along a fallback function if auto fallback is turned off', function () {
423
452
  mdl.options.autoQueryFallback = false;
424
453
  should.not.exist(mdl.sum().fallbackFn);
425
454
  });
426
-
427
- it('should pass query info to the QueryInterface instance', function(done) {
455
+
456
+ it('should pass query info to the QueryInterface instance', function (done) {
428
457
  var queryOptions = {};
429
-
430
- mdl.$query = function(options) {
458
+
459
+ mdl.$query = function (options) {
431
460
  options.query.should.equal('sum');
432
461
  options.queryOptions.length.should.equal(1);
433
462
  options.queryOptions[0].should.equal(queryOptions);
@@ -436,28 +465,28 @@ describe('Model', function () {
436
465
  mdl.sum(queryOptions);
437
466
  });
438
467
  });
439
-
468
+
440
469
  describe('#upsert', function () {
441
470
  var mdl;
442
471
  beforeEach(function () {
443
472
  mdl = new Model('foo');
444
473
  });
445
-
446
- it('should return the createdDefault value for the model', async function() {
474
+
475
+ it('should return the createdDefault value for the model', async function () {
447
476
  let res = await mdl.upsert();
448
477
  let created = await res.fallbackFn();
449
478
  created.should.equal(mdl.options.createdDefault);
450
479
  });
451
-
480
+
452
481
  it('should not pass along a fallback function if auto fallback is turned off', function () {
453
482
  mdl.options.autoQueryFallback = false;
454
483
  should.not.exist(mdl.upsert().fallbackFn);
455
484
  });
456
-
457
- it('should pass query info to the QueryInterface instance', function(done) {
485
+
486
+ it('should pass query info to the QueryInterface instance', function (done) {
458
487
  var queryOptions = {};
459
-
460
- mdl.$query = function(options) {
488
+
489
+ mdl.$query = function (options) {
461
490
  options.query.should.equal('upsert');
462
491
  options.queryOptions.length.should.equal(1);
463
492
  options.queryOptions[0].should.equal(queryOptions);
@@ -466,40 +495,40 @@ describe('Model', function () {
466
495
  mdl.upsert(queryOptions);
467
496
  });
468
497
  });
469
-
498
+
470
499
  describe('#findOrCreate', function () {
471
500
  var mdl;
472
501
  beforeEach(function () {
473
502
  mdl = new Model('foo');
474
503
  });
475
-
504
+
476
505
  it('should pass along where value to Instance creation', async function () {
477
506
  var options = {
478
507
  where: {
479
508
  'foo': 'bar',
480
509
  },
481
510
  };
482
-
511
+
483
512
  let res = await mdl.findOrCreate(options)
484
- let [inst, created] = await res.fallbackFn()
513
+ let [inst, created] = await res.fallbackFn()
485
514
  inst._args[0].should.have.property('foo').which.is.exactly('bar');
486
515
  });
487
-
516
+
488
517
  it('should return the createdDefault value for the model', async function () {
489
518
  let res = await mdl.findOrCreate({})
490
519
  let [inst, created] = await res.fallbackFn();
491
520
  created.should.equal(mdl.options.createdDefault);
492
521
  });
493
-
522
+
494
523
  it('should not pass along a fallback function if auto fallback is turned off', function () {
495
524
  mdl.options.autoQueryFallback = false;
496
525
  should.not.exist(mdl.findOrCreate().fallbackFn);
497
526
  });
498
-
499
- it('should pass query info to the QueryInterface instance', function(done) {
527
+
528
+ it('should pass query info to the QueryInterface instance', function (done) {
500
529
  var queryOptions = {};
501
-
502
- mdl.$query = function(options) {
530
+
531
+ mdl.$query = function (options) {
503
532
  options.query.should.equal('findOrCreate');
504
533
  options.queryOptions.length.should.equal(1);
505
534
  options.queryOptions[0].should.equal(queryOptions);
@@ -508,40 +537,40 @@ describe('Model', function () {
508
537
  mdl.findOrCreate(queryOptions);
509
538
  });
510
539
  });
511
-
540
+
512
541
  describe('#bulkCreate', function () {
513
542
  var mdl;
514
543
  beforeEach(function () {
515
544
  mdl = new Model('foo');
516
545
  });
517
-
546
+
518
547
  it('should create each model in the passed array', async function () {
519
548
  var vals = [
520
549
  {
521
- 'baz' : 'bin'
550
+ 'baz': 'bin'
522
551
  },
523
552
  {
524
- 'qux' : 'quuz'
553
+ 'qux': 'quuz'
525
554
  },
526
555
  ];
527
-
556
+
528
557
  let res = await mdl.bulkCreate(vals);
529
558
  let arr = await res.fallbackFn();
530
559
  arr.should.be.an.Array();
531
560
  arr[0]._args[0].should.have.property('baz').which.is.exactly('bin');
532
561
  arr[1]._args[0].should.have.property('qux').which.is.exactly('quuz');
533
562
  });
534
-
563
+
535
564
  it('should not pass along a fallback function if auto fallback is turned off', function () {
536
565
  mdl.options.autoQueryFallback = false;
537
566
  should.not.exist(mdl.bulkCreate().fallbackFn);
538
567
  });
539
-
540
- it('should pass query info to the QueryInterface instance', function(done) {
568
+
569
+ it('should pass query info to the QueryInterface instance', function (done) {
541
570
  var set = {};
542
571
  var opt = {};
543
-
544
- mdl.$query = function(options) {
572
+
573
+ mdl.$query = function (options) {
545
574
  options.query.should.equal('bulkCreate');
546
575
  options.queryOptions.length.should.equal(2);
547
576
  options.queryOptions[0].should.equal(set);
@@ -551,41 +580,41 @@ describe('Model', function () {
551
580
  mdl.bulkCreate(set, opt);
552
581
  });
553
582
  });
554
-
583
+
555
584
  describe('#findAll', function () {
556
585
  var mdl;
557
586
  beforeEach(function () {
558
587
  mdl = new Model('foo');
559
588
  });
560
-
589
+
561
590
  it('should pass along where value to Instance creation', async function () {
562
591
  var options = {
563
592
  where: {
564
593
  'foo': 'bar',
565
594
  },
566
595
  };
567
-
596
+
568
597
  let query = await mdl.findAll(options);
569
598
  let rows = await query.fallbackFn()
570
599
  rows.length.should.equal(1);
571
600
  rows[0]._args[0].should.have.property('foo').which.is.exactly('bar');
572
601
  });
573
-
574
- it('should still find results if there is not options', async function() {
602
+
603
+ it('should still find results if there is not options', async function () {
575
604
  let query = await mdl.findAll();
576
605
  let rows = await query.fallbackFn();
577
606
  rows.length.should.equal(1);
578
607
  });
579
-
608
+
580
609
  it('should not pass along a fallback function if auto fallback is turned off', function () {
581
610
  mdl.options.autoQueryFallback = false;
582
611
  should.not.exist(mdl.findAll().fallbackFn);
583
612
  });
584
-
585
- it('should pass query info to the QueryInterface instance', function(done) {
613
+
614
+ it('should pass query info to the QueryInterface instance', function (done) {
586
615
  var queryOptions = {};
587
-
588
- mdl.$query = function(options) {
616
+
617
+ mdl.$query = function (options) {
589
618
  options.query.should.equal('findAll');
590
619
  options.queryOptions.length.should.equal(1);
591
620
  options.queryOptions[0].should.equal(queryOptions);
@@ -594,43 +623,43 @@ describe('Model', function () {
594
623
  mdl.findAll(queryOptions)
595
624
  });
596
625
  });
597
-
626
+
598
627
  describe('#findAndCountAll', function () {
599
628
  var mdl;
600
629
  beforeEach(function () {
601
630
  mdl = new Model('foo');
602
631
  });
603
-
604
- it('should pass along where value to Instance creation', async function() {
632
+
633
+ it('should pass along where value to Instance creation', async function () {
605
634
  var options = {
606
635
  where: {
607
636
  'foo': 'bar',
608
637
  },
609
638
  };
610
-
639
+
611
640
  let query = await mdl.findAndCountAll(options);
612
- let result =await query.fallbackFn()
641
+ let result = await query.fallbackFn()
613
642
  result.rows.length.should.equal(1);
614
643
  result.count.should.equal(1);
615
644
  result.rows[0]._args[0].should.have.property('foo').which.is.exactly('bar');
616
645
  });
617
-
646
+
618
647
  it('should still find results if there is not options', async function () {
619
648
  let query = await mdl.findAndCountAll()
620
649
  let result = await query.fallbackFn()
621
650
  result.count.should.equal(1);
622
651
  result.rows.length.should.equal(1);
623
652
  });
624
-
653
+
625
654
  it('should not pass along a fallback function if auto fallback is turned off', function () {
626
655
  mdl.options.autoQueryFallback = false;
627
656
  should.not.exist(mdl.findAndCountAll().fallbackFn);
628
657
  });
629
-
630
- it('should pass query info to the QueryInterface instance', function(done) {
658
+
659
+ it('should pass query info to the QueryInterface instance', function (done) {
631
660
  var queryOptions = {};
632
-
633
- mdl.$query = function(options) {
661
+
662
+ mdl.$query = function (options) {
634
663
  options.query.should.equal('findAndCountAll');
635
664
  options.queryOptions.length.should.equal(1);
636
665
  options.queryOptions[0].should.equal(queryOptions);
@@ -645,31 +674,31 @@ describe('Model', function () {
645
674
  beforeEach(function () {
646
675
  mdl = new Model('foo');
647
676
  });
648
-
677
+
649
678
  it('should return a default value of 1 for number of rows destroyed', async function () {
650
679
  let query = await mdl.destroy();
651
680
  let rows = await query.fallbackFn()
652
681
  rows.should.equal(1);
653
-
682
+
654
683
  });
655
-
684
+
656
685
  it('should return the limit for number of rows destroyed if that is passed in', async function () {
657
686
  let query = await mdl.destroy({
658
687
  limit: 5
659
688
  })
660
689
  let rows = await query.fallbackFn()
661
- rows.should.equal(5);
690
+ rows.should.equal(5);
662
691
  });
663
-
692
+
664
693
  it('should not pass along a fallback function if auto fallback is turned off', function () {
665
694
  mdl.options.autoQueryFallback = false;
666
695
  should.not.exist(mdl.destroy().fallbackFn);
667
696
  });
668
-
669
- it('should pass query info to the QueryInterface instance', function(done) {
697
+
698
+ it('should pass query info to the QueryInterface instance', function (done) {
670
699
  var queryOptions = {};
671
-
672
- mdl.$query = function(options) {
700
+
701
+ mdl.$query = function (options) {
673
702
  options.query.should.equal('destroy');
674
703
  options.queryOptions.length.should.equal(1);
675
704
  options.queryOptions[0].should.equal(queryOptions);
@@ -678,18 +707,18 @@ describe('Model', function () {
678
707
  mdl.destroy(queryOptions);
679
708
  });
680
709
  });
681
-
710
+
682
711
  describe('#getTableName', function () {
683
712
  var mdl;
684
713
  beforeEach(function () {
685
714
  mdl = new Model('foo');
686
715
  });
687
-
716
+
688
717
  it('should return a default value of 1 for number of rows destroyed', function () {
689
718
  mdl.tableName = 'bar';
690
-
719
+
691
720
  mdl.getTableName().should.equal('bar');
692
721
  });
693
722
  });
694
-
723
+
695
724
  });