destroy.test.js
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require('../support'),
current = Support.sequelize,
sinon = require('sinon'),
DataTypes = require('../../../lib/data-types'),
_ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), () => {
describe('method destroy', () => {
const User = current.define('User', {
name: DataTypes.STRING,
secretValue: DataTypes.INTEGER
});
before(function() {
this.stubDelete = sinon.stub(current.getQueryInterface(), 'bulkDelete').resolves([]);
});
beforeEach(function() {
this.deloptions = { where: { secretValue: '1' } };
this.cloneOptions = _.clone(this.deloptions);
this.stubDelete.resetHistory();
});
afterEach(function() {
delete this.deloptions;
delete this.cloneOptions;
});
after(function() {
this.stubDelete.restore();
});
it('can detect complexe objects', () => {
const Where = function() { this.secretValue = '1'; };
expect(() => {
User.destroy({ where: new Where() });
}).to.throw();
});
});
});