Skip to content

Commit

Permalink
test: fix breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 30, 2019
1 parent 43fe9f7 commit d32f9f0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions test-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export async function resetTables () {
await db.table('users').truncate()
await db.table('profiles').truncate()
await db.table('identities').truncate()
await db.destroy()
}

/**
Expand Down
18 changes: 17 additions & 1 deletion test/database/query-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import test from 'japa'
import { Connection } from '../../src/Connection'
import { QueryClient } from '../../src/QueryClient'
import { getConfig, setup, cleanup, getLogger } from '../../test-helpers'
import { getConfig, setup, cleanup, getLogger, resetTables } from '../../test-helpers'

test.group('Query client', (group) => {
group.before(async () => {
Expand All @@ -23,6 +23,10 @@ test.group('Query client', (group) => {
await cleanup()
})

group.afterEach(async () => {
await resetTables()
})

test('get query client in dual mode', async (assert) => {
const connection = new Connection('primary', getConfig(), getLogger())
connection.connect()
Expand Down Expand Up @@ -60,6 +64,10 @@ test.group('Query client | dual mode', (group) => {
await cleanup()
})

group.afterEach(async () => {
await resetTables()
})

test('perform select queries in dual mode', async (assert) => {
const connection = new Connection('primary', getConfig(), getLogger())
connection.connect()
Expand Down Expand Up @@ -131,6 +139,10 @@ test.group('Query client | read mode', (group) => {
await cleanup()
})

group.afterEach(async () => {
await resetTables()
})

test('perform select queries in read mode', async (assert) => {
const connection = new Connection('primary', getConfig(), getLogger())
connection.connect()
Expand Down Expand Up @@ -194,6 +206,10 @@ test.group('Query client | write mode', (group) => {
await cleanup()
})

group.afterEach(async () => {
await resetTables()
})

test('perform select queries in write mode', async (assert) => {
const connection = new Connection('primary', getConfig(), getLogger())
connection.connect()
Expand Down
4 changes: 2 additions & 2 deletions test/orm/adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ test.group('Adapter', (group) => {
assert.isFalse(users[0].$isDirty)
assert.isFalse(users[1].$isDirty)

assert.deepEqual(users[0].$attributes, { id: 1, username: 'virk' })
assert.deepEqual(users[1].$attributes, { id: 2, username: 'nikk' })
assert.deepEqual(users[0].$attributes, { id: 2, username: 'nikk' })
assert.deepEqual(users[1].$attributes, { id: 1, username: 'virk' })
})
})

0 comments on commit d32f9f0

Please sign in to comment.