Skip to content

Commit

Permalink
test: fix base provider tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rickardlofberg committed Oct 6, 2023
1 parent fd86734 commit ca6d19d
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit ca6d19d

Please sign in to comment.