From ca6d19dfda55b9f2081b4abe4bb206cbd48a1c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rickard=20L=C3=B6fberg?= Date: Fri, 6 Oct 2023 11:26:11 +0200 Subject: [PATCH] test: fix base provider tests --- .../gameobjects/base/base-provider.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/gameengine/gameobjects/base/base-provider.spec.ts b/packages/backend/src/gameengine/gameobjects/base/base-provider.spec.ts index f4d8382d6..65b6c0e25 100755 --- a/packages/backend/src/gameengine/gameobjects/base/base-provider.spec.ts +++ b/packages/backend/src/gameengine/gameobjects/base/base-provider.spec.ts @@ -1,29 +1,37 @@ import { Board } from "../../board"; -import { createTestBoard } from "../../util"; +import { createTestBoard, createTestBot } from "../../util"; import { BotGameObject } from "../bot/bot"; import { BaseProvider } from "./base-provider"; let provider: BaseProvider; let board: Board; +let bot: BotGameObject; beforeEach(() => { provider = new BaseProvider(); board = createTestBoard(); + bot = createTestBot(); }); test("Creates base when bot joins", () => { - const bot = new BotGameObject({ x: 0, y: 0 }); + // Arrange + bot.position = { x: 0, y: 0 }; + // Act provider.onGameObjectsAdded(board, [bot]); + // Assert expect(bot.base).toBeDefined(); }); test("Removes base property when bot is removed", () => { - const bot = new BotGameObject({ x: 0, y: 0 }); + // Arrange + bot.position = { x: 0, y: 0 }; provider.onGameObjectsAdded(board, [bot]); + // Act provider.onGameObjectsRemoved(board, [bot]); + // Assert expect(bot.base).toEqual(null); });