Skip to content

Commit

Permalink
fix: fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyDaddy committed Feb 1, 2024
1 parent a527d45 commit 3369464
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions test/integration/suite/querying.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ describe('=> Group / Join / Subqueries', function() {
// https://github.com/cyjake/leoric/issues/417
// SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `comments`.`article_id` = `posts`.`id` WHERE `posts`.`gmt_deleted` IS NULL
assert.equal(Post.find().join(Comment, 'comments.articleId = posts.id').toSqlString(), Post.include('comments').toSqlString());
const posts = await Post.find().join(Comment, 'comments.articleId = posts.id');
const posts = await Post.find().join(Comment, 'comments.articleId = posts.id').order('posts.id');
assert.equal(posts.length, 4);

assert.equal(posts[0].comments.length, 0);
Expand All @@ -552,14 +552,14 @@ describe('=> Group / Join / Subqueries', function() {
// https://github.com/cyjake/leoric/issues/417
const posts = await Post.find().limit(1).join(Comment, 'comments.articleId = posts.id').where({
'posts.title': { $like: 'Archb%' },
});
}).order('posts.id');
assert.equal(posts.length, 1);
assert.ok(posts[0].comments[0] instanceof Comment);
});

it('Bone.find().join() without association', async function() {
// https://github.com/cyjake/leoric/issues/417
const posts = await Post.find().join(User, 'posts.authorId = users.id');
const posts = await Post.find().join(User, 'posts.authorId = users.id').order('posts.id');
assert.equal(posts.length, 4);

assert.ok(posts[0].users);
Expand All @@ -570,7 +570,7 @@ describe('=> Group / Join / Subqueries', function() {
// https://github.com/cyjake/leoric/issues/417
const posts = await Post.find().limit(1).join(User, 'posts.authorId = users.id').where({
'posts.title': { $like: 'Archb%' },
});
}).order('posts.id');
assert.equal(posts.length, 1);
assert.ok(posts[0].users instanceof User);
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/spell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ describe('=> Spell', function() {
it('arbitrary join', function() {
assert.equal(
Post.join(Comment, 'comments.articleId = posts.id').toString(),
'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `comments`.`article_id` = `posts`.`id` WHERE `posts`.`gmt_deleted` IS NULL'
'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `posts`.`id` = `comments`.`article_id` AND `comments`.`gmt_deleted` IS NULL WHERE `posts`.`gmt_deleted` IS NULL'
);

assert.equal(Post.include('comments').limit(1).toSqlString(), heresql(function () {
Expand Down Expand Up @@ -615,7 +615,7 @@ describe('=> Spell', function() {

assert.equal(
Post.join(Comment, 'comments.articleId = posts.id').limit(1).toString(),
'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `comments`.`article_id` = `posts`.`id` WHERE `posts`.`gmt_deleted` IS NULL LIMIT 1'
'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `posts`.`id` = `comments`.`article_id` AND `comments`.`gmt_deleted` IS NULL WHERE `posts`.`gmt_deleted` IS NULL LIMIT 1'
);

});
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"target": "ES2020",
},
"include": [
"src/**/*"
"src/**/*",
"test/**/*.ts"
],
"exclude": [
"dist",
Expand Down

0 comments on commit 3369464

Please sign in to comment.