diff options
| author | stonedDiscord <Tukz@gmx.de> | 2026-01-01 16:56:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-01 16:56:51 +0100 |
| commit | 33744e44ceaf3825da451ba38281fd84b255de80 (patch) | |
| tree | e6c080d7e8e6f56652c2269a380eff40b899a065 /webAO/__tests__/aoml.test.ts | |
| parent | e07fe372bc20d16eb590b68ed256007312b3801a (diff) | |
| parent | 01ecb948edb015613e05bc2b6da4021137957745 (diff) | |
Merge pull request #286 from AttorneyOnline/bnnuy
Bnnuy
Diffstat (limited to 'webAO/__tests__/aoml.test.ts')
| -rw-r--r-- | webAO/__tests__/aoml.test.ts | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/webAO/__tests__/aoml.test.ts b/webAO/__tests__/aoml.test.ts index b799da6..d612945 100644 --- a/webAO/__tests__/aoml.test.ts +++ b/webAO/__tests__/aoml.test.ts @@ -1,8 +1,4 @@ -import request from "../services/request"; -import mlConfig from "../utils/aoml"; - -jest.mock("../services/request"); -const networkRequest = ` +const configIni = ` c0 = 247, 247, 247 c0_name = White c0_talking = 1 @@ -36,73 +32,56 @@ c6_remove = 0 c6_talking = 0 `; -const mockRequest = request as jest.MockedFunction<typeof request>; -mockRequest.mockReturnValue(Promise.resolve(networkRequest)); - -describe("mlConfig", () => { - beforeEach(() => { - // Clear all instances and calls to constructor and all methods: - mockRequest.mockClear(); - }); +import mlConfig from "../utils/aoml"; - it("Should make a network request", () => { - mlConfig("localhost"); - expect(mockRequest).toHaveBeenCalledTimes(1); - }); -}); describe("applyMarkdown", () => { - const config = mlConfig("localhost"); - - beforeEach(() => { - // Clear all instances and calls to constructor and all methods: - mockRequest.mockClear(); - }); + 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("localhost"); - 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("localhost"); + 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("localhost"); + 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("localhost"); + 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("localhost"); + 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("localhost"); - 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); }); |
