Skip to content

Commit

Permalink
Correcting test of the function that turns search params into filters
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceo committed Nov 28, 2024
1 parent a71a5d5 commit 20732f7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions __tests__/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ReadonlyURLSearchParams } from "next/navigation"
import { beforeEach, describe, expect, it, vi } from "vitest"

import { getFacetsForSearchRequest } from "@/components/pages/searchPageLayout/helper"
import { getFacetMachineNames, getFacetTranslation } from "@/components/shared/searchFilters/helper"
import goConfig from "@/lib/config/goConfig"
import { FacetFieldEnum } from "@/lib/graphql/generated/fbi/graphql"
import { correctFacetNames } from "@/lib/machines/search/helpers"
import { correctFacetNames, transformSearchParamsIntoFilters } from "@/lib/machines/search/helpers"

vi.mock(import("@/lib/config/goConfig"), async importOriginal => {
const actual = await importOriginal()
Expand Down Expand Up @@ -60,7 +59,7 @@ describe("Facet functionality", () => {
])
})

it("getFacetsForSearchRequest should return an object with facet terms grouped by facet machine names", () => {
it("transformSearchParamsIntoFilters should return an object with facet terms grouped by facet machine names", () => {
const searchParams = new URLSearchParams()
searchParams.append("materialTypesGeneral", "Book")
searchParams.append("mainLanguages", "Danish")
Expand All @@ -79,7 +78,7 @@ describe("Facet functionality", () => {
subjects: ["Science", "Math"],
}

const result = getFacetsForSearchRequest(searchParams as ReadonlyURLSearchParams)
const result = transformSearchParamsIntoFilters(searchParams as ReadonlyURLSearchParams)
expect(result).toStrictEqual(facetFilters)
})

Expand Down

0 comments on commit 20732f7

Please sign in to comment.