The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore(test): add tests for resolveRelative

+30 -1
+30 -1
quartz/util/path.test.ts
··· 1 1 import test, { describe } from "node:test" 2 2 import * as path from "./path" 3 3 import assert from "node:assert" 4 - import { FullSlug, TransformOptions } from "./path" 4 + import { FullSlug, TransformOptions, SimpleSlug } from "./path" 5 5 6 6 describe("typeguards", () => { 7 7 test("isSimpleSlug", () => { ··· 314 314 }) 315 315 }) 316 316 }) 317 + 318 + describe("resolveRelative", () => { 319 + test("from index", () => { 320 + assert.strictEqual(path.resolveRelative("index" as FullSlug, "index" as FullSlug), "./") 321 + assert.strictEqual(path.resolveRelative("index" as FullSlug, "abc" as FullSlug), "./abc") 322 + assert.strictEqual(path.resolveRelative("index" as FullSlug, "abc/def" as FullSlug), "./abc/def") 323 + assert.strictEqual(path.resolveRelative("index" as FullSlug, "abc/def/ghi" as FullSlug), "./abc/def/ghi") 324 + }) 325 + 326 + test("from nested page", () => { 327 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "index" as FullSlug), "../") 328 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "abc" as FullSlug), "../abc") 329 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "abc/def" as FullSlug), "../abc/def") 330 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "ghi/jkl" as FullSlug), "../ghi/jkl") 331 + }) 332 + 333 + test("with index paths", () => { 334 + assert.strictEqual(path.resolveRelative("abc/index" as FullSlug, "index" as FullSlug), "../") 335 + assert.strictEqual(path.resolveRelative("abc/def/index" as FullSlug, "index" as FullSlug), "../../") 336 + assert.strictEqual(path.resolveRelative("index" as FullSlug, "abc/index" as FullSlug), "./abc/") 337 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "abc/index" as FullSlug), "../abc/") 338 + }) 339 + 340 + test("with simple slugs", () => { 341 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "" as SimpleSlug), "../") 342 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "ghi" as SimpleSlug), "../ghi") 343 + assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "ghi/" as SimpleSlug), "../ghi/") 344 + }) 345 + })