summary refs log tree commit diff
path: root/util/tests/User.test.js
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-27 11:11:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-27 11:11:16 +0200
commitc21c3428217d25c058a6fb9fe40bcfdc1cc1e1c1 (patch)
tree67f8265ba004ea5d576311f582c98d8a00676c2f /util/tests/User.test.js
parent:construction: api (diff)
downloadserver-c21c3428217d25c058a6fb9fe40bcfdc1cc1e1c1.tar.xz
:construction: typeorm
Diffstat (limited to 'util/tests/User.test.js')
-rw-r--r--util/tests/User.test.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/util/tests/User.test.js b/util/tests/User.test.js
new file mode 100644

index 00000000..b87c753d --- /dev/null +++ b/util/tests/User.test.js
@@ -0,0 +1,31 @@ +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(); + }); +});