From 28d428ae13211d48b458f0ca7b1d33799c3bded2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:04:36 +0000 Subject: [PATCH 1/3] Initial plan From fb76257d39ed47ce9c3025b27132e46bba0dfdd2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:26:00 +0000 Subject: [PATCH 2/3] Add comprehensive tests for getOutputPath function Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com> --- src/lib_test.ts | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/lib_test.ts diff --git a/src/lib_test.ts b/src/lib_test.ts new file mode 100644 index 0000000..589f4c4 --- /dev/null +++ b/src/lib_test.ts @@ -0,0 +1,92 @@ +import { getOutputPath } from "./lib.ts"; + +// Simple assertion helper +function assertEquals(actual: T, expected: T, msg?: string): void { + if (actual !== expected) { + throw new Error( + msg || `Expected ${JSON.stringify(expected)}, but got ${JSON.stringify(actual)}` + ); + } +} + +Deno.test("getOutputPath - default output without custom path", () => { + const result = getOutputPath({ + input: "Checker.png", + rationalAngle: { degrees: 45 }, + }); + assertEquals(result, "./Checker-tile-45.png"); +}); + +Deno.test("getOutputPath - with full path", () => { + const result = getOutputPath({ + input: "/path/to/Checker.png", + rationalAngle: { degrees: 45 }, + }); + assertEquals(result, "/path/to/Checker-tile-45.png"); +}); + +Deno.test("getOutputPath - with relative path", () => { + const result = getOutputPath({ + input: "./images/test.jpg", + rationalAngle: { degrees: 90 }, + }); + assertEquals(result, "./images/test-tile-90.jpg"); +}); + +Deno.test("getOutputPath - with custom output path", () => { + const result = getOutputPath({ + input: "Checker.png", + rationalAngle: { degrees: 45 }, + output: "custom-output.png", + }); + assertEquals(result, "custom-output.png"); +}); + +Deno.test("getOutputPath - with negative degrees", () => { + const result = getOutputPath({ + input: "test.png", + rationalAngle: { degrees: -45 }, + }); + assertEquals(result, "./test-tile--45.png"); +}); + +Deno.test("getOutputPath - with decimal degrees", () => { + const result = getOutputPath({ + input: "/home/user/image.png", + rationalAngle: { degrees: 26.565 }, + }); + assertEquals(result, "/home/user/image-tile-26.565.png"); +}); + +Deno.test("getOutputPath - with different file extension", () => { + const result = getOutputPath({ + input: "photo.jpeg", + rationalAngle: { degrees: 90 }, + }); + assertEquals(result, "./photo-tile-90.jpeg"); +}); + +Deno.test("getOutputPath - zero degrees", () => { + const result = getOutputPath({ + input: "./assets/background.png", + rationalAngle: { degrees: 0 }, + }); + assertEquals(result, "./assets/background-tile-0.png"); +}); + +Deno.test("getOutputPath - preserves directory structure", () => { + const result = getOutputPath({ + input: "../../parent/child/file.png", + rationalAngle: { degrees: 45 }, + }); + assertEquals(result, "../../parent/child/file-tile-45.png"); +}); + +Deno.test("getOutputPath - custom output ignores input path structure", () => { + const result = getOutputPath({ + input: "/some/long/path/to/image.png", + rationalAngle: { degrees: 63.435 }, + output: "./output.png", + }); + assertEquals(result, "./output.png"); +}); From 2b4b19098004d5efba3315bd9230860c2d5b6e36 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:26:36 +0000 Subject: [PATCH 3/3] Use standard Deno assertion library and add @std/assert to imports Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com> --- deno.json | 1 + src/lib_test.ts | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/deno.json b/deno.json index b61140f..cca59f8 100644 --- a/deno.json +++ b/deno.json @@ -1,5 +1,6 @@ { "imports": { + "@std/assert": "jsr:@std/assert@^1.0.15", "@std/cli": "jsr:@std/cli@^1.0.27", "@std/fs": "jsr:@std/fs@^1.0.22", "@std/path": "jsr:@std/path@^1.1.4", diff --git a/src/lib_test.ts b/src/lib_test.ts index 589f4c4..06040d4 100644 --- a/src/lib_test.ts +++ b/src/lib_test.ts @@ -1,14 +1,6 @@ +import { assertEquals } from "jsr:@std/assert"; import { getOutputPath } from "./lib.ts"; -// Simple assertion helper -function assertEquals(actual: T, expected: T, msg?: string): void { - if (actual !== expected) { - throw new Error( - msg || `Expected ${JSON.stringify(expected)}, but got ${JSON.stringify(actual)}` - ); - } -} - Deno.test("getOutputPath - default output without custom path", () => { const result = getOutputPath({ input: "Checker.png",