Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sscce-sequelize-7.ts #258

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/sscce-sequelize-7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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([ 'postgres', 'postgres-native']);

// You can delete this file if you don't want your SSCCE to be tested against Sequelize 7

Expand All @@ -21,13 +21,14 @@ export async function run() {
},
});

class Foo extends Model {}
class User extends Model {}

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

// You can use sinon and chai assertions directly in your SSCCE.
Expand All @@ -36,6 +37,20 @@ export async function run() {
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);
const attributes = ['name'];
const created = await User.create({ name: 'Foo', password: 'pass' }, {returning: attributes});
console.log(created);
expect(created.name).to.equal('Foo);
expect(created.password).to.be.undefined;
const updatedWithChange = await User.update({name:'Bar'}, {where: {id: created.id}, returning: attributes, individualHooks: true});
console.log(updatedWithChange)
expect(updatedWithChange[1][0].name).to.equal('Bar');
expect(updatedWithChange[1][0].password).to.be.undefined;
const updatedNoChange = await User.update({name:undefined}, {where: {id: created.id}, returning: attributes, individualHooks: true});
console.log(updatedNoChange)
expect(updatedWithChange[1][0].name).to.equal('Bar');
expect(updatedWithChange[1][0].password).to.be.undefined;

//expect(await Foo.count()).to.equal(1);
await User.up
}