feat(utils): export xo connection

This commit is contained in:
Julien Fontanet
2016-12-23 17:51:17 +01:00
parent 7a7db1ea08
commit 8890d445dc
2 changed files with 13 additions and 11 deletions

View File

@@ -4,22 +4,15 @@ import {
createUser,
deleteUsers,
getConnection,
getMainConnection,
getUser
getUser,
xo
} from './util'
// ===================================================================
describe('user', () => {
let xo
let userIds = []
beforeAll(async () => {
xo = await getMainConnection()
})
afterAll(() => xo.close())
afterEach(async () => {
await deleteUsers(xo, userIds)
userIds = []

View File

@@ -1,7 +1,9 @@
import expect from 'must'
import Xo from 'xo-lib'
import XoCollection from 'xo-collection'
import {find, forEach, map, once, cloneDeep} from 'lodash'
import {find, forEach, map, cloneDeep} from 'lodash'
/* eslint-env jest */
export async function getConfig () {
return {
@@ -103,7 +105,14 @@ export async function getConnection ({
return xo
}
export const getMainConnection = once(getConnection)
export let xo
beforeAll(async () => {
xo = await getConnection()
})
afterAll(async () => {
await xo.close()
xo = null
})
// =================================================================