/
bulk-create.test.js
44 lines (37 loc) · 1.08 KB
/
bulk-create.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
'use strict';
const chai = require('chai'),
expect = chai.expect,
sinon = require('sinon'),
Support = require('../support'),
DataTypes = require('sequelize/lib/data-types'),
current = Support.sequelize;
describe(Support.getTestDialectTeaser('Model'), () => {
describe('bulkCreate', () => {
before(function() {
this.Model = current.define('model', {
accountId: {
type: DataTypes.INTEGER(11).UNSIGNED,
allowNull: false,
field: 'account_id'
}
}, { timestamps: false });
this.stub = sinon.stub(current.getQueryInterface(), 'bulkInsert').resolves([]);
});
afterEach(function() {
this.stub.resetHistory();
});
after(function() {
this.stub.restore();
});
describe('validations', () => {
it('should not fail for renamed fields', async function() {
await this.Model.bulkCreate([
{ accountId: 42 }
], { validate: true });
expect(this.stub.getCall(0).args[1]).to.deep.equal([
{ account_id: 42, id: null }
]);
});
});
});
});