Skip to content

Commit

Permalink
🔨 fix db tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Mar 16, 2024
1 parent 27e3109 commit 4de4a18
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions db/tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ beforeAll(async () => {
knexInstance = knex(dbTestConfig)

const fixturesCreator = new sqlFixtures(knexInstance)
fixturesCreator.create(dataSpec, function (err: any, _: any) {
if (err) console.error(err)
// In case you want to see results of fixture creation you can do it like below
// console.log(_.users[0].email)
})
await fixturesCreator.create(dataSpec)
})

afterAll((done: any) => {
Expand All @@ -55,6 +51,7 @@ test("it can query a user created in fixture via TypeORM", async () => {
.table(UsersTableName)
.where({ email: "[email protected]" })
.first<DbPlainUser>()
expect(user).toBeTruthy()
expect(user.id).toBe(1)
expect(user.email).toBe("[email protected]")
})
Expand Down Expand Up @@ -170,7 +167,7 @@ test("knex interface", async () => {
const usersFromRawQueryWithInClauseAsArray: Pick<
DbPlainUser,
"email"
>[] = await knexRaw(trx, "select * from users where email in ?", [
>[] = await knexRaw(trx, "select * from users where email in (?)", [
[usersFromRawQuery[0].email, usersFromRawQuery[1].email],
])
expect(usersFromRawQueryWithInClauseAsArray.length).toBe(2)
Expand Down

0 comments on commit 4de4a18

Please sign in to comment.