diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-08-22 22:18:59 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-08-22 22:18:59 +1000 |
commit | 0cd9a46eea260c299db2e2983f7214ab8b119d29 (patch) | |
tree | 5fbb98e7adcfeab81594732089474afdde5893f9 /tests/User.test.js | |
parent | Merge branch 'master' into feat/captchaVerify (diff) | |
parent | Merge remote-tracking branch 'Puyodead1/patch/prettier-config' into staging (diff) | |
download | server-0cd9a46eea260c299db2e2983f7214ab8b119d29.tar.xz |
Merge remote-tracking branch 'upstream/staging' into feat/captchaVerify
Diffstat (limited to 'tests/User.test.js')
-rw-r--r-- | tests/User.test.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/User.test.js b/tests/User.test.js new file mode 100644 index 00000000..c0852ebc --- /dev/null +++ b/tests/User.test.js @@ -0,0 +1,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); + } + }); +}); |