diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-24 16:35:39 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-24 16:35:39 +0200 |
commit | 271e439b1a1e756f2410e25766d587479c668a7d (patch) | |
tree | e1584ef22d21a366830861392444f354ce6ab9ee /util/tests | |
parent | :construction: gateway (diff) | |
download | server-271e439b1a1e756f2410e25766d587479c668a7d.tar.xz |
:white_check_mark: util unit tests
Diffstat (limited to 'util/tests')
-rw-r--r-- | util/tests/validate.test.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/util/tests/validate.test.js b/util/tests/validate.test.js new file mode 100644 index 00000000..629c864f --- /dev/null +++ b/util/tests/validate.test.js @@ -0,0 +1,27 @@ +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); + }); +}); |