Files
speckle-server/packages/server/modules/core/tests/init.spec.ts
T
Kristaps Fabians Geikins d2f2d95bb5 chore(server): migrate remaining tests to TS (#4772)
* auth tests migrated

* core tests

* pwdreset

* authz tests
2025-05-20 14:24:48 +03:00

56 lines
1.6 KiB
TypeScript

/* istanbul ignore file */
import { expect } from 'chai'
import { init } from '@/app'
import { knex } from '@/db/knex'
import { beforeEachContext } from '@/test/hooks'
// NOTE:
// These tests check that the initialization routine of the whole server
// correctly registers some scopes and roles. At the time of writing, there are
// 11 scopes and 5 roles. These might increase in the future with additional
// modules being added.
describe('Initialization Logic @init-logic', () => {
describe('First init', () => {
before(async () => {
await beforeEachContext()
})
it('should have a lotta scopes', async () => {
const res = await knex('scopes').select()
expect(res.length).to.be.greaterThan(10)
})
it('should have some roles', async () => {
const res = await knex('user_roles').select()
expect(res.length).to.be.greaterThan(4)
})
it('should have some apps', async () => {
const res = await knex('server_apps').select()
expect(res.length).to.be.greaterThan(2)
})
})
describe('Second init', () => {
before(async () => {
await init()
})
it('should have a lotta scopes second time round too!', async () => {
const res = await knex('scopes').select()
expect(res.length).to.be.greaterThan(10)
})
it('should have some roles second time round!', async () => {
const res = await knex('user_roles').select()
expect(res.length).to.be.greaterThan(4)
})
it('should have some apps second time round', async () => {
const res = await knex('server_apps').select()
expect(res.length).to.be.greaterThan(2)
})
})
})