Skip to content

Commit

Permalink
Add Bug Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-dumont committed Mar 3, 2024
1 parent 1230359 commit 57abdd1
Showing 1 changed file with 44 additions and 14 deletions.
58 changes: 44 additions & 14 deletions src/sscce-sequelize-7.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { DataTypes, Model } from '@sequelize/core';
import { createSequelize7Instance } from '../dev/create-sequelize-instance';
import { expect } from 'chai';
import sinon from 'sinon';
import { DataTypes, Model } from "@sequelize/core";
import { createSequelize7Instance } 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']);
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 7

Expand All @@ -22,20 +29,43 @@ export async function run() {
});

class Foo extends Model {}
class Bar extends Model {}

Foo.init({
name: DataTypes.TEXT,
}, {
sequelize,
modelName: 'Foo',
});
Foo.init(
{
name: DataTypes.TEXT,
},
{
sequelize,
modelName: "Foo",
}
);

Bar.init(
{
name: DataTypes.TEXT,
},
{
sequelize,
modelName: "BAR",
}
);

Bar.belongsTo(Foo);
Foo.hasMany(Bar);

// 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);
await Foo.create({ name: "TS foo" });
await Bar.create({ name: "Bar1", FooId: 1 });
await Bar.create({ name: "Bar2", FooId: 1 });

const data = await Foo.findAll({
include: { all: true },
});

expect(Object.keys(data).includes("BARs")).to.be.true;
}

0 comments on commit 57abdd1

Please sign in to comment.