-
Notifications
You must be signed in to change notification settings - Fork 346
/
sscce-sequelize-6.ts
41 lines (34 loc) · 1.25 KB
/
sscce-sequelize-6.ts
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
import { DataTypes, Model } from 'sequelize';
import { createSequelize6Instance } from '../dev/create-sequelize-instance';
import { expect } from 'chai';
import sinon from 'sinon';
// if your issue is dialect specific, remove the dialects you don't need to test on.
export const testingOnDialects = new Set(['mssql', 'sqlite', 'mysql', 'mariadb', 'postgres', 'postgres-native']);
// You can delete this file if you don't want your SSCCE to be tested against Sequelize 6
// Your SSCCE goes inside this function.
export async function run() {
// This function should be used instead of `new Sequelize()`.
// It applies the config for your SSCCE to work on CI.
const sequelize = createSequelize6Instance({
logQueryParameters: true,
benchmark: true,
define: {
// For less clutter in the SSCCE
timestamps: false,
},
});
class Foo extends Model {}
Foo.init({
name: DataTypes.TEXT,
}, {
sequelize,
modelName: 'Foo',
});
// You can use sinon and chai assertions directly in your SSCCE.
const spy = sinon.spy();
sequelize.afterBulkSync(() => spy());
await sequelize.sync({ force: true });
expect(spy).to.have.been.called;
console.log(await Foo.create({ name: 'TS foo' }));
expect(await Foo.count()).to.equal(1);
}