1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 13:14:06 +01:00
server/util/tests/validate.test.js

28 lines
680 B
JavaScript
Raw Normal View History

2021-08-24 16:35:39 +02:00
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);
});
});