Skip to content

Commit

Permalink
add more test to the Color Test Unit on recycling Color instance from…
Browse files Browse the repository at this point in the history
… the pool
  • Loading branch information
obiot committed Aug 6, 2024
1 parent fd8eeb0 commit 1692f41
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/melonjs/tests/color.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeAll, describe, expect, it } from "vitest";
import { Color } from "../src/index.js";
import { Color, getPool } from "../src/index.js";

describe("Color", () => {
let red_color: Color;
Expand Down Expand Up @@ -30,6 +30,24 @@ describe("Color", () => {
});
});

describe("get a Color instance from the pool", () => {
const pColor = getPool("color").get(0, 128, 0, 1);
it("creates a new Color instance with default values", () => {
expect(pColor.r).toEqual(0);
expect(pColor.g).toEqual(128);
expect(pColor.b).toEqual(0);
expect(pColor.alpha).toEqual(1);
});

it("get Color instance from the pool using another Color object as parameter", () => {
const pColor2 = getPool("color").get(pColor);
expect(pColor2.r).toEqual(0);
expect(pColor2.g).toEqual(128);
expect(pColor2.b).toEqual(0);
expect(pColor2.alpha).toEqual(1);
});
});

describe("parseHex Function", () => {
// #RGB
it("#00F value is rgb(0, 0, 255)", () => {
Expand Down

0 comments on commit 1692f41

Please sign in to comment.