-
Notifications
You must be signed in to change notification settings - Fork 2
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 #293 from nulib/deploy/staging
Production push
- Loading branch information
Showing
11 changed files
with
1,137 additions
and
719 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { render, screen } from "@/test-utils"; | ||
|
||
import SearchSimilar from "./Similar"; | ||
|
||
describe("SearchSimilar component", () => { | ||
const mockSetShowSimilar = jest.fn(); | ||
const props = { | ||
handleClose: mockSetShowSimilar, | ||
work: { | ||
id: "abc123", | ||
title: "ima source work for similar results", | ||
}, | ||
}; | ||
|
||
it("renders the Work title and a link to the Work page", () => { | ||
render(<SearchSimilar {...props} />); | ||
const title = screen.getByText(/ima source work for similar results/i); | ||
expect(title).toBeInTheDocument(); | ||
|
||
expect( | ||
screen.getByRole("link", { name: /ima source work for similar results/i }) | ||
).toHaveAttribute("href", "/items/abc123"); | ||
}); | ||
|
||
it("renders a close button, which calls a callback fn", () => { | ||
render(<SearchSimilar {...props} />); | ||
const button = screen.getByRole("button", { name: /close/i }); | ||
expect(button).toBeInTheDocument(); | ||
button.click(); | ||
expect(mockSetShowSimilar).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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,65 @@ | ||
import Announcement from "@/components/Shared/Announcement"; | ||
import { IconClear } from "@/components/Shared/SVG/Icons"; | ||
import Link from "next/link"; | ||
import React from "react"; | ||
import { styled } from "@/stitches.config"; | ||
|
||
interface Props { | ||
handleClose: () => void; | ||
work: { | ||
id: string; | ||
title: string; | ||
}; | ||
} | ||
|
||
/* eslint sort-keys: 0 */ | ||
|
||
const SimilarWrapper = styled(Announcement, { | ||
marginBottom: "$gr4", | ||
paddingTop: "$gr1", | ||
paddingBottom: "$gr1", | ||
}); | ||
|
||
const SimilarStyled = styled("div", { | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
color: "$purple", | ||
position: "relative", | ||
|
||
"& button": { | ||
position: "absolute", | ||
right: 0, | ||
background: "transparent", | ||
border: "none", | ||
cursor: "pointer", | ||
|
||
"& span": { | ||
display: "none", | ||
}, | ||
|
||
"& svg": { | ||
width: "$gr3", | ||
height: "$gr3", | ||
}, | ||
}, | ||
}); | ||
|
||
const SearchSimilar: React.FC<Props> = ({ handleClose, work }) => { | ||
return ( | ||
<SimilarWrapper> | ||
<SimilarStyled> | ||
<p> | ||
You are viewing works similar to{" "} | ||
<Link href={`/items/${work?.id}`}>{work?.title}</Link> | ||
</p> | ||
<button type="button" onClick={handleClose}> | ||
<span>Close</span> | ||
<IconClear /> | ||
</button> | ||
</SimilarStyled> | ||
</SimilarWrapper> | ||
); | ||
}; | ||
|
||
export default SearchSimilar; |
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
Oops, something went wrong.