blob: c0852ebc29d2ea600166192d8a9c514ea4f1f5ea (
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
34
35
36
37
38
39
40
41
42
43
|
const { initDatabase, closeDatabase } = require("../dist/util/Database");
const { User } = require("../dist/entities/User");
jest.setTimeout(20000);
beforeAll((done) => {
initDatabase().then(() => {
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();
});
test("add guild", async () => {
try {
await new User({ guilds: [], discriminator: "1" }, { id: "0" }).save();
const user = await User.find("0");
user.guilds.push(new Guild({ name: "test" }));
user.save();
} catch (error) {
console.error(error);
}
});
});
|