2022-11-07 19:06:58 +01:00
|
|
|
import dotenv from 'dotenv'
|
|
|
|
import chai from 'chai'
|
|
|
|
import http from 'chai-http'
|
|
|
|
import { verifyConfig } from '../src/config.mjs'
|
|
|
|
import { randomString } from '../src/utils/crypto.mjs'
|
|
|
|
import { userTests } from './user.mjs'
|
2022-11-07 20:42:07 +01:00
|
|
|
import { accountTests } from './account.mjs'
|
2022-11-07 19:06:58 +01:00
|
|
|
import { apikeyTests } from './apikey.mjs'
|
|
|
|
import { setup } from './shared.mjs'
|
|
|
|
|
|
|
|
dotenv.config()
|
|
|
|
|
|
|
|
const config = verifyConfig()
|
|
|
|
const expect = chai.expect
|
|
|
|
chai.use(http)
|
|
|
|
|
|
|
|
// Account data
|
|
|
|
const store = {
|
|
|
|
account: {
|
|
|
|
email: `test_${randomString()}@${config.tests.domain}`,
|
|
|
|
language: 'en',
|
|
|
|
password: randomString(),
|
|
|
|
},
|
2022-11-07 19:50:51 +01:00
|
|
|
icons: {
|
|
|
|
user: '🧑 ',
|
|
|
|
jwt: '🎫 ',
|
|
|
|
key: '🎟️ ',
|
|
|
|
},
|
2022-11-07 19:06:58 +01:00
|
|
|
}
|
2022-11-07 19:50:51 +01:00
|
|
|
store.icon = (icon1, icon2 = false) => store.icons[icon1] + (icon2 ? store.icons[icon2] : '')
|
2022-11-07 19:06:58 +01:00
|
|
|
|
|
|
|
// Run tests
|
|
|
|
const runTests = async (config, store, chai) => {
|
|
|
|
await setup(config, store, chai)
|
2022-11-07 20:42:07 +01:00
|
|
|
await userTests(config, store, chai)
|
2022-11-08 21:04:32 +01:00
|
|
|
await apikeyTests(config, store, chai)
|
2022-11-07 20:42:07 +01:00
|
|
|
//await accountTests(config, store, chai)
|
2022-11-07 19:06:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Do the work
|
|
|
|
runTests(config, store, chai)
|