summary refs log tree commit diff
path: root/util/tests/User.test.js
diff options
context:
space:
mode:
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();
+	});
+});