blob: 434422f895fa980a2ba84614e0d4eb8a6e8617db (
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
28
29
30
31
32
33
|
const { initDatabase, closeDatabase } = require("../dist/util/Database");
const { User } = require("../dist/entities/User");
jest.setTimeout(10000);
beforeAll((done) => {
initDatabase().then(() => {
new User().validate(); // warm up schema/model
done();
});
});
afterAll(() => {
closeDatabase();
});
describe("Validate model class properties", () => {
test("object instead of string", async () => {
expect(() => {
new User({}, { id: {} }).validate();
}).toThrow();
});
test("validation should be faster than 20ms", () => {
expect(() => {
new User().validate();
}).toBeFasterThan(20);
});
test("should not set opts", () => {
const user = new User({ opts: { id: 0 } });
expect(user.opts.id).not.toBe(0);
});
});
|