-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from danskernesdigitalebibliotek/DDFBRA-263-vi…
…-skaber-performance-problemer-hos-dbc fix: issue where calls are made to the API with no identifier on useGetV1ProductsIdentifier + add tests + cleanup and refactor related logic
- Loading branch information
Showing
8 changed files
with
112 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { expect, test } from "vitest" | ||
|
||
import { | ||
ManifestationIdentifiersFragment, | ||
WorkTeaserSearchPageFragment, | ||
} from "@/lib/graphql/generated/fbi/graphql" | ||
import { getIsbnsFromManifestation, getIsbnsFromWork } from "@/lib/helpers/ids" | ||
|
||
test("test that we can get isbns from manifestation", async () => { | ||
const manifestation = { | ||
pid: "870970-basis:29142246", | ||
identifiers: [ | ||
{ | ||
type: "PUBLIZON", | ||
value: "9788711402740", | ||
}, | ||
{ | ||
type: "ISBN", | ||
value: "9788711402740", | ||
}, | ||
{ | ||
type: "ISBN", | ||
value: "9788711402742", | ||
}, | ||
], | ||
} as ManifestationIdentifiersFragment | ||
|
||
const isbns = getIsbnsFromManifestation(manifestation) | ||
|
||
expect(isbns).toStrictEqual(["9788711402740", "9788711402742"]) | ||
}) | ||
|
||
test("test that we get empty isbns when only having publizon identifiers", async () => { | ||
const manifestation = { | ||
pid: "870970-basis:29142246", | ||
identifiers: [ | ||
{ | ||
type: "PUBLIZON", | ||
value: "9788711402740", | ||
}, | ||
], | ||
} as ManifestationIdentifiersFragment | ||
|
||
const isbns = getIsbnsFromManifestation(manifestation) | ||
|
||
expect(isbns).toStrictEqual([]) | ||
}) | ||
|
||
test("test that we get an array of isbns string from work object", async () => { | ||
const work = { | ||
manifestations: { | ||
all: [ | ||
{ | ||
pid: "870970-basis:29142246", | ||
identifiers: [ | ||
{ | ||
type: "PUBLIZON", | ||
value: "9788711402740", | ||
}, | ||
{ | ||
type: "ISBN", | ||
value: "9788711402740", | ||
}, | ||
], | ||
materialTypes: [ | ||
{ | ||
materialTypeGeneral: { | ||
display: "e-bøger", | ||
code: "EBOOKS", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
bestRepresentation: {}, | ||
}, | ||
} as Pick<WorkTeaserSearchPageFragment, "manifestations"> | ||
|
||
const isbns = getIsbnsFromWork(work as WorkTeaserSearchPageFragment) | ||
|
||
expect(isbns).toStrictEqual(["9788711402740"]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ import type { | |
|
||
/** | ||
* Sample **request**: | ||
GET /friendly | ||
{ | ||
"name": "Some name" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters