From 7c7d2349c59c623130c782d03534bfa2ca554bd7 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 1 Jan 2026 16:09:13 +0100 Subject: test syntax --- webAO/__tests__/aoml.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/__tests__/aoml.test.ts') diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index b799da6..8e8b36d 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -1,7 +1,7 @@ import request from "../services/request"; import mlConfig from "../utils/aoml"; -jest.mock("../services/request"); +jest.mock("../services/request", () => ({})); const networkRequest = ` c0 = 247, 247, 247 c0_name = White -- cgit From e7a7afa4527a2289ebbbad659048f4db368e9c4c Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 1 Jan 2026 16:34:03 +0100 Subject: pass aoml test --- webAO/__tests__/aoml.test.ts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'webAO/__tests__/aoml.test.ts') diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index 8e8b36d..0ce97b8 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -1,7 +1,6 @@ import request from "../services/request"; import mlConfig from "../utils/aoml"; -jest.mock("../services/request", () => ({})); const networkRequest = ` c0 = 247, 247, 247 c0_name = White @@ -36,26 +35,30 @@ c6_remove = 0 c6_talking = 0 `; -const mockRequest = request as jest.MockedFunction; -mockRequest.mockReturnValue(Promise.resolve(networkRequest)); +// Mock the request module properly +jest.mock("../services/request", () => ({ + __esModule: true, + default: jest.fn().mockResolvedValue(networkRequest), + request: jest.fn().mockResolvedValue(networkRequest) +})); describe("mlConfig", () => { beforeEach(() => { // Clear all instances and calls to constructor and all methods: - mockRequest.mockClear(); + jest.clearAllMocks(); }); it("Should make a network request", () => { - mlConfig("localhost"); - expect(mockRequest).toHaveBeenCalledTimes(1); + mlConfig("/"); + expect(request).toHaveBeenCalledTimes(1); }); }); describe("applyMarkdown", () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); beforeEach(() => { // Clear all instances and calls to constructor and all methods: - mockRequest.mockClear(); + jest.clearAllMocks(); }); it("Should create an array of spans containing letters", async () => { @@ -68,40 +71,40 @@ describe("applyMarkdown", () => { } }); it("Should add colors based on settings", async () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); const actual = await config.applyMarkdown(`(heya)`, `blue`); expect(actual[0].getAttribute("style")).toBe("color: rgb(107, 198, 247);"); }); it("Should keep a letter if remove = 0", async () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); const actual = await config.applyMarkdown(`(What())Hey!`, `white`); const expected = `(`; expect(actual[5].innerHTML).toBe(expected); }); it("Should remove a letter if remove = 1", async () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); const actual = await config.applyMarkdown(`~What~()Hey!`, `white`); const expected = ``; expect(actual[0].innerHTML).toBe(expected); }); it("Should remove a letter if remove = 1", async () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); const actual = await config.applyMarkdown(`~What~()Hey!`, `white`); const expected = ``; expect(actual[0].innerHTML).toBe(expected); }); it("Should keep a closing letter if remove = 0", async () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); const actual = await config.applyMarkdown(`~NO[]~!`, `white`); const expected = ``; expect(actual[4].innerHTML).toBe(expected); }); it("Should remove a closing letter if remove = 1", async () => { - const config = mlConfig("localhost"); + const config = mlConfig("/"); const actual = await config.applyMarkdown(`~NO||~!`, `white`); const expected = ``; expect(actual[5].innerHTML).toBe(expected); -- cgit From 56db8cc6d68748ecdd163c27d4cf7e5dfd8e295f Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 1 Jan 2026 16:41:27 +0100 Subject: weird ci fail --- webAO/__tests__/aoml.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'webAO/__tests__/aoml.test.ts') diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index 0ce97b8..f518863 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -39,7 +39,8 @@ c6_talking = 0 jest.mock("../services/request", () => ({ __esModule: true, default: jest.fn().mockResolvedValue(networkRequest), - request: jest.fn().mockResolvedValue(networkRequest) + request: jest.fn().mockResolvedValue(networkRequest), + requestBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(0)) })); describe("mlConfig", () => { -- cgit From b247ed9347921e395e34e5cf19085f529de4c307 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 1 Jan 2026 16:44:28 +0100 Subject: try this --- webAO/__tests__/aoml.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'webAO/__tests__/aoml.test.ts') diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index f518863..54f0a56 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -43,6 +43,12 @@ jest.mock("../services/request", () => ({ requestBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(0)) })); +// Ensure the mock is applied before any imports +beforeAll(() => { + jest.clearAllMocks(); + console.log("Mock applied:", request); +}); + describe("mlConfig", () => { beforeEach(() => { // Clear all instances and calls to constructor and all methods: -- cgit From 70f8c13634f1ae13cdf52994c7b6c44a20398c02 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 1 Jan 2026 16:46:44 +0100 Subject: reorder --- webAO/__tests__/aoml.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'webAO/__tests__/aoml.test.ts') diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index 54f0a56..8cc4967 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -1,6 +1,3 @@ -import request from "../services/request"; -import mlConfig from "../utils/aoml"; - const networkRequest = ` c0 = 247, 247, 247 c0_name = White @@ -43,6 +40,9 @@ jest.mock("../services/request", () => ({ requestBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(0)) })); +import request from "../services/request"; +import mlConfig from "../utils/aoml"; + // Ensure the mock is applied before any imports beforeAll(() => { jest.clearAllMocks(); -- cgit From 01ecb948edb015613e05bc2b6da4021137957745 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 1 Jan 2026 16:56:17 +0100 Subject: deal with this properly --- webAO/__tests__/aoml.test.ts | 75 +++++++++++++------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) (limited to 'webAO/__tests__/aoml.test.ts') diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index 8cc4967..d612945 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -1,4 +1,4 @@ -const networkRequest = ` +const configIni = ` c0 = 247, 247, 247 c0_name = White c0_talking = 1 @@ -32,87 +32,56 @@ c6_remove = 0 c6_talking = 0 `; -// Mock the request module properly -jest.mock("../services/request", () => ({ - __esModule: true, - default: jest.fn().mockResolvedValue(networkRequest), - request: jest.fn().mockResolvedValue(networkRequest), - requestBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(0)) -})); - -import request from "../services/request"; import mlConfig from "../utils/aoml"; -// Ensure the mock is applied before any imports -beforeAll(() => { - jest.clearAllMocks(); - console.log("Mock applied:", request); -}); - -describe("mlConfig", () => { - beforeEach(() => { - // Clear all instances and calls to constructor and all methods: - jest.clearAllMocks(); - }); - - it("Should make a network request", () => { - mlConfig("/"); - expect(request).toHaveBeenCalledTimes(1); - }); -}); describe("applyMarkdown", () => { - const config = mlConfig("/"); - - beforeEach(() => { - // Clear all instances and calls to constructor and all methods: - jest.clearAllMocks(); - }); + const config = mlConfig(configIni); - it("Should create an array of spans containing letters", async () => { + it("Should create an array of spans containing letters", () => { const word = `hello`; - const actual = await config.applyMarkdown(`hello`, `blue`); + const actual = config.applyMarkdown(`hello`, `blue`); let index = 0; for (const element of actual) { expect(element.innerHTML).toBe(word[index]); index++; } }); - it("Should add colors based on settings", async () => { - const config = mlConfig("/"); - const actual = await config.applyMarkdown(`(heya)`, `blue`); + it("Should add colors based on settings", () => { + const config = mlConfig(configIni); + const actual = config.applyMarkdown(`(heya)`, `blue`); expect(actual[0].getAttribute("style")).toBe("color: rgb(107, 198, 247);"); }); - it("Should keep a letter if remove = 0", async () => { - const config = mlConfig("/"); + it("Should keep a letter if remove = 0", () => { + const config = mlConfig(configIni); - const actual = await config.applyMarkdown(`(What())Hey!`, `white`); + const actual = config.applyMarkdown(`(What())Hey!`, `white`); const expected = `(`; expect(actual[5].innerHTML).toBe(expected); }); - it("Should remove a letter if remove = 1", async () => { - const config = mlConfig("/"); + it("Should remove a letter if remove = 1", () => { + const config = mlConfig(configIni); - const actual = await config.applyMarkdown(`~What~()Hey!`, `white`); + const actual = config.applyMarkdown(`~What~()Hey!`, `white`); const expected = ``; expect(actual[0].innerHTML).toBe(expected); }); - it("Should remove a letter if remove = 1", async () => { - const config = mlConfig("/"); + it("Should remove a letter if remove = 1", () => { + const config = mlConfig(configIni); - const actual = await config.applyMarkdown(`~What~()Hey!`, `white`); + const actual = config.applyMarkdown(`~What~()Hey!`, `white`); const expected = ``; expect(actual[0].innerHTML).toBe(expected); }); - it("Should keep a closing letter if remove = 0", async () => { - const config = mlConfig("/"); + it("Should keep a closing letter if remove = 0", () => { + const config = mlConfig(configIni); - const actual = await config.applyMarkdown(`~NO[]~!`, `white`); + const actual = config.applyMarkdown(`~NO[]~!`, `white`); const expected = ``; expect(actual[4].innerHTML).toBe(expected); }); - it("Should remove a closing letter if remove = 1", async () => { - const config = mlConfig("/"); - const actual = await config.applyMarkdown(`~NO||~!`, `white`); + it("Should remove a closing letter if remove = 1", () => { + const config = mlConfig(configIni); + const actual = config.applyMarkdown(`~NO||~!`, `white`); const expected = ``; expect(actual[5].innerHTML).toBe(expected); }); -- cgit