diff --git a/common/player.test.ts b/common/player.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cfc37f4a20d270ef49f795f8d4a40c09ff01288 --- /dev/null +++ b/common/player.test.ts @@ -0,0 +1,21 @@ +import { io, Socket } from "socket.io-client"; +import Player from "./Player"; +import { Sushi } from "./Ressources"; +(global as any).Image = function () {}; + +describe("sizeIncrease", () => { + it("should increase by 0.5", function () { + const p = new Player(0, 0, 20, "goku", 1, 1, "test"); + const sushis: Sushi[] = [new Sushi(0, 0, 5)]; + const socket: Socket = io(); + p.eatSushi(sushis, socket); + expect(p.radius).toBe(20.5); + }); + it("should change form every 80", function () { + const p = new Player(0, 0, 79.5, "goku", 1, 1, "test"); + const sushis: Sushi[] = [new Sushi(0, 0, 5)]; + const socket: Socket = io(); + p.eatSushi(sushis, socket); + expect(p.image.src).toBe("/images/character/goku/goku2.png"); + }); +}); diff --git a/jest.config.cjs b/jest.config.cjs new file mode 100644 index 0000000000000000000000000000000000000000..b413e106db66e6c7150b76da0fc542e797db4034 --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; \ No newline at end of file