Skip to content

Commit

Permalink
Use string for search params issuance
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcohen committed Dec 12, 2023
1 parent 417f23a commit 903a570
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
20 changes: 13 additions & 7 deletions src/components/ItemTable/ItemAvailability.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("ItemAvailability", () => {
it("renders the correct text when item is available, has an aeon url, and has a location endpoint", async () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
render(<ItemAvailability item={item} />)
screen.getByText(/Available by appointment/)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(
screen.getByRole("link", {
name: "Schwarzman Building - Main Reading Room 315",
Expand All @@ -39,23 +39,29 @@ describe("ItemAvailability", () => {
it("renders the correct text for an available onsite item", async () => {
const item = new Item(itemAvailableOnsite, parentBib)
render(<ItemAvailability item={item} />)
screen.getByText(/Available/)
screen.getByText(/- Can be used on site. Please visit/)
expect(screen.getByText("Available")).toBeInTheDocument()
expect(
screen.getByText("- Can be used on site. Please visit", { exact: false })
).toBeInTheDocument()
expect(
screen.getByRole("link", {
name: "New York Public Library - Schwarzman Building M2",
})
).toHaveAttribute("href", "https://www.nypl.org/locations/schwarzman")
screen.getByText(/to submit a request in person./)
expect(
screen.getByText("to submit a request in person.", { exact: false })
).toBeInTheDocument()
})
it("renders the correct text for unavailable items", async () => {
const item = new Item(itemUnavailable, parentBib)
render(<ItemAvailability item={item} />)
screen.getByText(/Not available/)
screen.getByText(/- Please/)
expect(screen.getByText("Not available")).toBeInTheDocument()
expect(screen.getByText("- Please", { exact: false })).toBeInTheDocument()
screen.getByRole("button", {
name: "contact a librarian",
})
screen.getByText(/for assistance./)
expect(
screen.getByText("for assistance.", { exact: false })
).toBeInTheDocument()
})
})
9 changes: 6 additions & 3 deletions src/models/SearchResultsBib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class SearchResultsBib {
materialType?: string
publicationStatement?: string
electronicResources?: ElectronicResource[]
issuance?: JSONLDValue
issuance?: JSONLDValue[]
numPhysicalItems: number
items: Item[]

Expand All @@ -36,7 +36,7 @@ export default class SearchResultsBib {
? result.publicationStatement[0]
: null
this.electronicResources = result.electronicResources || null
this.issuance = (result.issuance?.length && result.issuance[0]) || null
this.issuance = (result.issuance?.length && result.issuance) || null
this.numPhysicalItems = result.numItemsTotal || 0
this.items = this.getItemsFromResult(result)
}
Expand All @@ -51,7 +51,10 @@ export default class SearchResultsBib {

// Used to determine the Volume column text in the ItemTable
get isArchiveCollection() {
return this.issuance["@id"] === "urn:biblevel:c"
return (
Array.isArray(this.issuance) &&
this.issuance.some((issuance) => issuance["@id"] === "urn:biblevel:c")
)
}

get hasItems() {
Expand Down

0 comments on commit 903a570

Please sign in to comment.