-
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.
* moved share to separate component * dropdown menu added * added styling and icons for menu * corrected svgs * unit tests for share menu added * Adding svgs as components * all share svgs imported as components * updated tests for share
- Loading branch information
Showing
15 changed files
with
5,123 additions
and
1,940 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { jest } from "@jest/globals"; | ||
import React from "react"; | ||
|
||
const createMockIcon = (testId: string) => { | ||
const MockIcon = () => <svg data-testid={testId} />; | ||
MockIcon.displayName = `Mock${testId.charAt(0).toUpperCase() + testId.slice(1)}Icon`; | ||
return MockIcon; | ||
}; | ||
|
||
jest.mock("../../img/icon-share.svg", () => createMockIcon("share-icon")); | ||
jest.mock("../../img/icon-facebook.svg", () => createMockIcon("facebook-icon")); | ||
jest.mock("../../img/icon-email.svg", () => createMockIcon("email-icon")); | ||
jest.mock("../../img/icon-x.svg", () => createMockIcon("x-icon")); | ||
jest.mock("../../img/icon-link.svg", () => createMockIcon("link-icon")); |
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,44 @@ | ||
import { render, screen, waitFor } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import Share from "../share"; | ||
import "@testing-library/jest-dom"; | ||
|
||
describe("Share Component", () => { | ||
it("renders the Share button", () => { | ||
render(<Share />); | ||
const button = screen.getByText(/share report/i); | ||
expect(button).toBeInTheDocument(); | ||
}); | ||
|
||
// it("renders the menu options when the Share button is clicked", async () => { | ||
// render(<Share />); | ||
// const user = userEvent.setup(); | ||
// const button = screen.getByText(/share report/i); | ||
|
||
// button.style.pointerEvents = "auto"; | ||
|
||
// await user.click(button); | ||
|
||
// const emailOption = screen.getByText(/email/i); | ||
// const facebookOption = screen.getByText(/facebook/i); | ||
// const xOption = screen.getByText(/x/i); | ||
// expect(emailOption).toBeInTheDocument(); | ||
// expect(facebookOption).toBeInTheDocument(); | ||
// expect(xOption).toBeInTheDocument(); | ||
// }); | ||
|
||
// it("triggers a click on a menu item", async () => { | ||
// render(<Share />); | ||
// const user = userEvent.setup(); | ||
|
||
// const button = screen.getByText(/share report/i); | ||
// button.style.pointerEvents = "auto"; | ||
// await user.click(button); | ||
|
||
// const emailOption = await screen.getByText(/email/i); | ||
// await waitFor(() => expect(emailOption).toBeVisible()); | ||
|
||
// await userEvent.click(emailOption); | ||
// expect(emailOption).toBeDefined(); | ||
// }); | ||
}); |
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,48 @@ | ||
import { | ||
Text, | ||
Button, | ||
Menu, | ||
MenuButton, | ||
MenuList, | ||
MenuItem, | ||
} from "@chakra-ui/react"; | ||
import ShareIcon from "../img/icon-share.svg"; | ||
import FacebookIcon from "../img/icon-facebook.svg"; | ||
import EmailIcon from "../img/icon-email.svg"; | ||
import XIcon from "../img/icon-x.svg"; | ||
import LinkIcon from "../img/icon-link.svg"; | ||
|
||
const Share = () => { | ||
return ( | ||
<Menu> | ||
<MenuButton | ||
as={Button} | ||
aria-label="Share report" | ||
variant="ghost" | ||
rightIcon={<ShareIcon />} | ||
> | ||
<Text textStyle="textMedium">Share report</Text> | ||
</MenuButton> | ||
<MenuList p={"6px 16px 6px 16px"}> | ||
<MenuItem gap="10px"> | ||
<EmailIcon /> | ||
<Text>Email</Text> | ||
</MenuItem> | ||
<MenuItem gap="10px"> | ||
<FacebookIcon /> | ||
<Text>Facebook</Text> | ||
</MenuItem> | ||
<MenuItem gap="10px"> | ||
<XIcon /> | ||
<Text>X</Text> | ||
</MenuItem> | ||
<MenuItem gap="10px"> | ||
<LinkIcon /> | ||
<Text>Copy Link</Text> | ||
</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
); | ||
}; | ||
|
||
export default Share; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.