/
destroy.test.js
51 lines (45 loc) · 1.39 KB
/
destroy.test.js
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
48
49
50
51
'use strict';
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, current = Support.sequelize
, Sequelize = Support.Sequelize
, sinon = require('sinon');
describe(Support.getTestDialectTeaser('Instance'), function() {
describe('destroy', function () {
describe('options tests', function() {
var stub
, Model = current.define('User', {
id: {
type: Sequelize.BIGINT,
primaryKey: true,
autoIncrement: true,
}
})
, instance;
before(function() {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve({
_previousDataValues: {},
dataValues: {id: 1}
})
);
});
after(function() {
stub.restore();
});
it('should allow destroies even if options are not given', function () {
instance = Model.build({id: 1}, {isNewRecord: false});
expect(function () {
instance.destroy();
}).to.not.throw();
});
it('should not modify options when it given to destroy', function () {
instance = Model.build({id: 1}, {isNewRecord: false});
var options = { transaction: null };
instance.destroy(options);
expect(options).to.deep.equal({ transaction: null });
});
});
});
});