forked from sequelize/sequelize-sscce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sscce.js
36 lines (28 loc) · 1.1 KB
/
sscce.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
'use strict';
// Require the necessary things from Sequelize
const { Sequelize, Op, Model, DataTypes } = require('sequelize');
// This function should be used instead of `new Sequelize()`.
// It applies the config for your SSCCE to work on CI.
const createSequelizeInstance = require('./utils/create-sequelize-instance');
// This is an utility logger that should be preferred over `console.log()`.
const log = require('./utils/log');
// You can use sinon and chai assertions directly in your SSCCE if you want.
const sinon = require('sinon');
const { expect } = require('chai');
// Your SSCCE goes inside this function.
module.exports = async function() {
const sequelize = createSequelizeInstance({
logQueryParameters: true,
benchmark: true,
define: {
timestamps: false // For less clutter in the SSCCE
}
});
const Foo = sequelize.define('Foo', { name: DataTypes.TEXT });
const spy = sinon.spy();
sequelize.afterBulkSync(() => spy());
await sequelize.sync();
expect(spy).to.have.been.called;
log(await Foo.create({ name: 'foo' }));
expect(await Foo.count()).to.equal(1);
};