1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00
server/util/tests/User.test.js
Flam3rboy 845e77eed2 🚧 typeorm
2021-08-27 11:11:16 +02:00

32 lines
712 B
JavaScript

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("User", () => {
test("valid discriminator: 1", async () => {
new User({ discriminator: "1" }).validate();
});
test("invalid discriminator: test", async () => {
expect(() => {
new User({ discriminator: "test" }).validate();
}).toThrow();
});
test("invalid discriminator: 0", async () => {
expect(() => {
new User({ discriminator: "0" }).validate();
}).toThrow();
});
});