SW-3572 API route for listing hotels per city or country * wip hotel data endpoint * Correct route params type * wip * skip static paths call * timeout when getting destinations take too long * call noStore when we get a timeout * add cache-control headers * . * . * . * wip * wip * wip * wip * add route for getting hotels per country * include city when listing by country * fix distance SI unit * fix sorting * Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/SW-3572-hotel-data-endpoint * packages/tracking passWithNoTests * revalidate must be static value * remove oxc reference * cleanup * cleanup hotel api route * feat(SW-3572): cleanup error handling Approved-by: Anton Gunnarsson
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
|
|
import { equalsIgnoreCase, equalsIgnoreCaseAndAccents } from "./stringEquals"
|
|
|
|
describe("equalsIgnoreCase", () => {
|
|
it("returns true for identical strings", () => {
|
|
expect(equalsIgnoreCase("Hello", "Hello")).toBe(true)
|
|
})
|
|
|
|
it("is case-insensitive for ASCII letters", () => {
|
|
expect(equalsIgnoreCase("Hello", "hello")).toBe(true)
|
|
expect(equalsIgnoreCase("TEST", "test")).toBe(true)
|
|
})
|
|
|
|
it("returns false for different strings", () => {
|
|
expect(equalsIgnoreCase("apple", "apricot")).toBe(false)
|
|
})
|
|
|
|
it("handles empty strings", () => {
|
|
expect(equalsIgnoreCase("", "")).toBe(true)
|
|
expect(equalsIgnoreCase("", " ")).toBe(false)
|
|
})
|
|
|
|
it("takes diacritics into account", () => {
|
|
expect(equalsIgnoreCase("resume", "résumé")).toBe(false)
|
|
})
|
|
|
|
it("treats composed and decomposed forms as equal", () => {
|
|
// composed vs decomposed (e + combining acute)
|
|
expect(equalsIgnoreCase("é", "e\u0301")).toBe(true)
|
|
})
|
|
|
|
it("considers whitespace and length differences significant", () => {
|
|
expect(equalsIgnoreCase(" hello", "hello")).toBe(false)
|
|
expect(equalsIgnoreCase("hello", "hello ")).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe("equalsIgnoreCaseAndAccents", () => {
|
|
it("returns true for identical strings", () => {
|
|
expect(equalsIgnoreCaseAndAccents("Hello", "Hello")).toBe(true)
|
|
})
|
|
|
|
it("is case-insensitive for ASCII letters", () => {
|
|
expect(equalsIgnoreCaseAndAccents("Hello", "hello")).toBe(true)
|
|
expect(equalsIgnoreCaseAndAccents("TEST", "test")).toBe(true)
|
|
})
|
|
|
|
it("returns false for different strings", () => {
|
|
expect(equalsIgnoreCaseAndAccents("apple", "apricot")).toBe(false)
|
|
})
|
|
|
|
it("handles empty strings", () => {
|
|
expect(equalsIgnoreCaseAndAccents("", "")).toBe(true)
|
|
expect(equalsIgnoreCaseAndAccents("", " ")).toBe(false)
|
|
})
|
|
|
|
it("ignores diacritics / treats composed and decomposed forms as equal (sensitivity: base)", () => {
|
|
expect(equalsIgnoreCaseAndAccents("resume", "résumé")).toBe(true)
|
|
// composed vs decomposed (e + combining acute)
|
|
expect(equalsIgnoreCaseAndAccents("é", "e\u0301")).toBe(true)
|
|
})
|
|
|
|
it("considers whitespace and length differences significant", () => {
|
|
expect(equalsIgnoreCaseAndAccents(" hello", "hello")).toBe(false)
|
|
expect(equalsIgnoreCaseAndAccents("hello", "hello ")).toBe(false)
|
|
})
|
|
})
|