-
-
Notifications
You must be signed in to change notification settings - Fork 768
/
Copy pathcore.test.ts
51 lines (47 loc) · 1.53 KB
/
core.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import dbInit, { type ITestDb } from '../../test/e2e/helpers/database-init';
import { SYSTEM_USER } from './core';
import getLogger from '../../test/fixtures/no-logger';
describe('System user definitions in code and db', () => {
let dbDefinition: {
email: string | null;
username: string;
name: string;
id: number;
image_url: string | null;
};
let db: ITestDb;
beforeAll(async () => {
jest.setTimeout(15000);
db = await dbInit('system_user_alignment_test', getLogger);
const query = await db.rawDatabase.raw(
`select * from users where id = -1337;`,
);
dbDefinition = query.rows[0];
});
afterAll(async () => {
await db.destroy();
});
test('usernames match', () => {
expect(SYSTEM_USER.username).toBe(dbDefinition.username);
});
test('ids match', () => {
expect(SYSTEM_USER.id).toBe(dbDefinition.id);
});
test('names match', () => {
expect(SYSTEM_USER.name).toBe(dbDefinition.name);
});
test('emails match', () => {
expect('email' in SYSTEM_USER).toBe(false);
expect(dbDefinition.email).toBe(null);
});
test('image URLs are both falsy', () => {
expect(Boolean(SYSTEM_USER.imageUrl)).toBe(
Boolean(dbDefinition.image_url),
);
});
test('isApi is false on variable definition', () => {
// we don't set this in the DB, so let's just test the
// definition
expect(SYSTEM_USER.isAPI).toBe(false);
});
});