mirror of
https://github.com/theoludwig/theoludwig.git
synced 2025-12-12 20:46:52 +01:00
build: update to Node.js v24.0.0, pnpm v10, Tailwind CSS v4
This commit is contained in:
80
packages/utils/src/test/urls.test.ts
Normal file
80
packages/utils/src/test/urls.test.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { describe, it } from "node:test"
|
||||
import { LOCALE_DEFAULT } from "../constants.ts"
|
||||
import { getPathnameWithoutLocale } from "../urls.ts"
|
||||
|
||||
describe("urls", () => {
|
||||
describe("getPathnameWithoutLocale", () => {
|
||||
it("should return the pathname without the known locale prefix", () => {
|
||||
// Arrange - Given
|
||||
const input = `/${LOCALE_DEFAULT}/about`
|
||||
|
||||
// Act - When
|
||||
const output = getPathnameWithoutLocale(input)
|
||||
|
||||
// Assert - Then
|
||||
const expected = "/about"
|
||||
assert.strictEqual(output, expected)
|
||||
})
|
||||
|
||||
it("should return the same pathname when the input does not start with a known locale prefix", () => {
|
||||
// Arrange - Given
|
||||
const input = "/about"
|
||||
|
||||
// Act - When
|
||||
const output = getPathnameWithoutLocale(input)
|
||||
|
||||
// Assert - Then
|
||||
const expected = "/about"
|
||||
assert.strictEqual(output, expected)
|
||||
})
|
||||
|
||||
it("should return the same pathname when the input starts with an unknown locale prefix", () => {
|
||||
// Arrange - Given
|
||||
const input = "/abc-ABC/about"
|
||||
|
||||
// Act - When
|
||||
const output = getPathnameWithoutLocale(input)
|
||||
|
||||
// Assert - Then
|
||||
const expected = "/abc-ABC/about"
|
||||
assert.strictEqual(output, expected)
|
||||
})
|
||||
|
||||
it("should return the index route when the input is an empty string", () => {
|
||||
// Arrange - Given
|
||||
const input = ""
|
||||
|
||||
// Act - When
|
||||
const output = getPathnameWithoutLocale(input)
|
||||
|
||||
// Assert - Then
|
||||
const expected = "/"
|
||||
assert.strictEqual(output, expected)
|
||||
})
|
||||
|
||||
it("should return the index route when the input starts with a known locale prefix and with a trailing slash", () => {
|
||||
// Arrange - Given
|
||||
const input = `/${LOCALE_DEFAULT}/`
|
||||
|
||||
// Act - When
|
||||
const output = getPathnameWithoutLocale(input)
|
||||
|
||||
// Assert - Then
|
||||
const expected = "/"
|
||||
assert.strictEqual(output, expected)
|
||||
})
|
||||
|
||||
it("should return the index route when the input starts with a known locale prefix and without a trailing slash", () => {
|
||||
// Arrange - Given
|
||||
const input = `/${LOCALE_DEFAULT}`
|
||||
|
||||
// Act - When
|
||||
const output = getPathnameWithoutLocale(input)
|
||||
|
||||
// Assert - Then
|
||||
const expected = "/"
|
||||
assert.strictEqual(output, expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user