Skip to content

Commit

Permalink
chore: unit test complete
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyDaddy committed Sep 26, 2022
1 parent f731ac9 commit d7e7bba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/types/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ describe('=> Basics (TypeScript)', function() {
assert.equal(post.changed(), false);
assert.equal(post.changed('title'), false);
});

it('bone.attributeWas(name)',async () => {
const post = new Post({
title: 'Yhorm',
});
await post.save();
post.attribute('title', 'Cain');
assert.equal(post.attributeWas('title'), 'Yhorm');
});
});

describe('=> Accessors', function() {
Expand Down Expand Up @@ -240,10 +249,12 @@ describe('=> Basics (TypeScript)', function() {
it('post.update()', async function() {
const post = await Post.create({ title: 'Tyrael' });
assert.equal(post.title, 'Tyrael');
const result = await post.update({ title: 'Stranger' });
let result = await post.update({ title: 'Stranger' });
assert.equal(result, 1);
await post.reload();
assert.equal(post.title, 'Stranger');
result = await post.update({});
assert.equal(result, 0);
});

it('spell.increment()', async function() {
Expand Down
18 changes: 18 additions & 0 deletions test/types/sequelize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,13 @@ describe('=> sequelize (TypeScript)', function() {
assert.equal(result, 1);
await post.reload();
assert.equal(post.title, 'Stranger');
const result1 = await post.update({ title: 'Stranger', content: 'Yhorm' }, {
fields: [ 'content' ],
});
assert.equal(result1, 1);
await post.reload();
assert.equal(post.title, 'Stranger');
assert.equal(post.content, 'Yhorm');
});

it('spell.increment()', async function() {
Expand Down Expand Up @@ -1389,4 +1396,15 @@ describe('=> sequelize (TypeScript)', function() {
Like.removeAttribute('userId');
assert(Like.attributes.userId == null);
});

it('transaction support pass null', async function() {
const post = await Post.create({ title: 'By three they come' }, { transaction: null });
const result = await Post.find({
where: {
title: 'By three they come',
},
transaction: null,
});
assert.equal(result.id, post.id);
});
});

0 comments on commit d7e7bba

Please sign in to comment.