decrement.test.js
1.06 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
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require(__dirname + '/../support'),
current = Support.sequelize,
Sequelize = Support.Sequelize,
sinon = require('sinon');
describe(Support.getTestDialectTeaser('Instance'), () => {
describe('decrement', () => {
describe('options tests', () => {
let stub, instance;
const Model = current.define('User', {
id: {
type: Sequelize.BIGINT,
primaryKey: true,
autoIncrement: true
}
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve({
_previousDataValues: {id: 3},
dataValues: {id: 1}
})
);
});
after(() => {
stub.restore();
});
it('should allow decrements even if options are not given', () => {
instance = Model.build({id: 3}, {isNewRecord: false});
expect(() => {
instance.decrement(['id']);
}).to.not.throw();
});
});
});
});