Skip to content

Commit

Permalink
Update sscce-sequelize-6.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ron-dadon authored Aug 22, 2024
1 parent c547c3b commit 5eaa2e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sscce-sequelize-6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ export async function run() {
nonTransactionCb();
}

await Foo.create({ name: 'A' });
await Bar.create({ name: 'A' });
expect(nonTransactionCb).to.have.been.called;
expect(afterCommitCb).not.to.have.been.called;

resetSpy();

await Foo.findOrCreate({ where: { name: 'B' } });
await Bar.findOrCreate({ where: { name: 'B' } });
expect(nonTransactionCb).not.to.have.been.called;
expect(afterCommitCb).to.have.been.called;

resetSpy();

await sequelize.transaction(async (transaction) => {
await Foo.create({ name: 'C' }, { transaction });
await Bar.create({ name: 'C' }, { transaction });
});
expect(nonTransactionCb).not.to.have.been.called;
expect(afterCommitCb).to.have.been.called;
Expand All @@ -78,7 +78,7 @@ export async function run() {

await sequelize.transaction(async (transaction) => {
transaction.afterCommit(() => internalAfterCommitCb());
await Foo.findOrCreate({ where: { name: 'D' }, transaction });
await Bar.findOrCreate({ where: { name: 'D' }, transaction });
});
expect(internalAfterCommitCb).to.have.been.called;
expect(nonTransactionCb).not.to.have.been.called;
Expand Down

0 comments on commit 5eaa2e4

Please sign in to comment.