Merged in feature/autocomplete-search (pull request #1725)
Feature/autocomplete search * wip autocomplete search * add skeletons to loading * Using aumlauts/accents when searching will still give results remove unused reducer sort autocomplete results * remove testcode * Add tests for autocomplete * cleanup tests * use node@20 * use node 22 * use node22 * merge fix: search button outside of viewport * merge * remove more unused code * fix: error message when empty search field in booking widget * fix: don't display empty white box when search field is empty and no searchHistory is present * merge * fix: set height of shimmer for search skeleton * rename autocomplete trpc -> destinationsAutocomplete * more accute cache key naming * fix: able to control wether bookingwidget is visible on startPage fix: sticky booking widget under alert * remove unused code * fix: skeletons fix: error overlay on search startpage * remove extra .nvmrc * merge Approved-by: Linus Flood
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "@jest/globals"
|
||||
|
||||
import { getSearchTokens } from "./getSearchTokens"
|
||||
|
||||
import type { DeepPartial } from "@/types/DeepPartial"
|
||||
import type { Location } from "@/types/trpc/routers/hotel/locations"
|
||||
|
||||
describe("getSearchTokens", () => {
|
||||
it("should return lowercased tokens for a hotel location", () => {
|
||||
const location: DeepPartial<Location> = {
|
||||
keyWords: ["Beach", "Luxury"],
|
||||
name: "Grand Hotel",
|
||||
type: "hotels",
|
||||
relationships: { city: { name: "Stockholm" } },
|
||||
}
|
||||
|
||||
const result = getSearchTokens(location as Location)
|
||||
expect(result).toEqual(["beach", "luxury", "grand hotel", "stockholm"])
|
||||
})
|
||||
|
||||
it("should generate additional tokens for diacritics replacement on a non-hotel location", () => {
|
||||
const location: DeepPartial<Location> = {
|
||||
keyWords: ["Ångström", "Café"],
|
||||
name: "München",
|
||||
country: "Frånce",
|
||||
type: "cities",
|
||||
}
|
||||
|
||||
const result = getSearchTokens(location as Location)
|
||||
expect(result).toEqual([
|
||||
"ångström",
|
||||
"café",
|
||||
"münchen",
|
||||
"frånce",
|
||||
"angstrom",
|
||||
"cafe",
|
||||
"munchen",
|
||||
"france",
|
||||
])
|
||||
})
|
||||
|
||||
it("should filter out empty or falsey tokens", () => {
|
||||
const location: DeepPartial<Location> = {
|
||||
keyWords: ["", "Valid"],
|
||||
name: "",
|
||||
type: "hotels",
|
||||
relationships: { city: { name: "" } },
|
||||
}
|
||||
|
||||
const result = getSearchTokens(location as Location)
|
||||
expect(result).toEqual(["valid"])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user