-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd86734
commit ca6d19d
Showing
1 changed file
with
11 additions
and
3 deletions.
There are no files selected for viewing
14 changes: 11 additions & 3 deletions
14
packages/backend/src/gameengine/gameobjects/base/base-provider.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |