Skip to content

Commit

Permalink
test: update test case for raw query
Browse files Browse the repository at this point in the history
  • Loading branch information
kiddyuchina committed Aug 6, 2024
1 parent 83f7703 commit 0ce4c32
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,22 @@ describe('Integration test', () => {

describe('raw', () => {
it('should execute raw SQL query and return correct result', async () => {
const user = await connection.raw('SELECT id FROM users WHERE id > ? LIMIT 1', [1]);
expect(user).toEqual([{
id: 2
}]);
if (process.env.DB === 'sqlite') {
const user = await connection.raw('SELECT id FROM users WHERE id > ? LIMIT 1', [1]);
expect(user).toEqual([{
id: 2
}]);
} else if (process.env.DB === 'mysql') {
const res = await connection.raw('SELECT id FROM users WHERE id > ? LIMIT 1', [1]);
expect(res[0]).toEqual([{
id: 2
}]);
} else if (process.env.DB === 'postgres') {
const res = await connection.raw('SELECT id FROM users WHERE id > ? LIMIT 1', [1]);
expect(res.rows).toEqual([{
id: 2
}]);
}
});
});

Expand Down

0 comments on commit 0ce4c32

Please sign in to comment.