From b51ce518477950db685c761fea30753138f9567f Mon Sep 17 00:00:00 2001 From: gparant Date: Mon, 4 May 2020 08:44:07 +0200 Subject: [PATCH] Fix unit test --- back/tests/MessageTest.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/back/tests/MessageTest.ts b/back/tests/MessageTest.ts index b3ce545..3bae787 100644 --- a/back/tests/MessageTest.ts +++ b/back/tests/MessageTest.ts @@ -3,14 +3,15 @@ import {Message} from "../src/Model/Websocket/Message"; describe("Message Model", () => { it("should find userId and roomId", () => { - let message = {userId: "test1", roomId: "test2"}; + let message = {userId: "test1", roomId: "test2", name: "foo"}; let messageObject = new Message(message); expect(messageObject.userId).toBe("test1"); expect(messageObject.roomId).toBe("test2"); + expect(messageObject.name).toBe("foo"); }) it("should expose a toJson method", () => { - let message = {userId: "test1", roomId: "test2"}; + let message = {userId: "test1", roomId: "test2", name: "foo"}; let messageObject = new Message(message); expect(messageObject.toJson()).toEqual({userId: "test1", roomId: "test2", name: "foo"}); }) @@ -28,4 +29,11 @@ describe("Message Model", () => { let messageObject = new Message(message); }).toThrow(new Error("userId or roomId cannot be null")); }) + + it("should find throw error when no roomId", () => { + let message = {name: "foo"}; + expect(() => { + let messageObject = new Message(message); + }).toThrow(new Error("userId or roomId cannot be null")); + }) }) \ No newline at end of file -- 2.25.1