schema.test.js
1.15 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
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require('./support'),
DataTypes = require('../../lib/data-types');
describe(Support.getTestDialectTeaser('Schema'), () => {
beforeEach(async function() {
await this.sequelize.createSchema('testschema');
});
afterEach(async function() {
await this.sequelize.dropSchema('testschema');
});
beforeEach(async function() {
this.User = this.sequelize.define('User', {
aNumber: { type: DataTypes.INTEGER }
}, {
schema: 'testschema'
});
await this.User.sync({ force: true });
});
it('supports increment', async function() {
const user0 = await this.User.create({ aNumber: 1 });
const result = await user0.increment('aNumber', { by: 3 });
const user = await result.reload();
expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(4);
});
it('supports decrement', async function() {
const user0 = await this.User.create({ aNumber: 10 });
const result = await user0.decrement('aNumber', { by: 3 });
const user = await result.reload();
expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(7);
});
});