blob: 629c864f8ab2476d7398c2a7751ed7dd8051c7ee (
plain) (
blame)
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
|
const { initDatabase } = require("../dist/util/Database");
const { User } = require("../dist/entities/User");
beforeAll(async () => {
await initDatabase();
new User().validate(); // initalize schema validator
});
describe("Validate model class properties", () => {
describe("validation should be faster than 20ms", () => {
expect(() => new User().validate()).toBeFasterThan(20);
});
describe("User", () => {
test("object instead of string", () => {
expect(() => {
new User({ username: {} }).validate();
}).toThrow();
});
});
test("should not set opts", () => {
const user = new User({ opts: { id: 0 } });
expect(user.opts.id).not.toBe(0);
});
});
|