Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
84 changes: 84 additions & 0 deletions src/lib_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { assertEquals } from "jsr:@std/assert";
import { getOutputPath } from "./lib.ts";

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");
});