-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c59228d
commit f69f79e
Showing
3 changed files
with
75 additions
and
31 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 |
---|---|---|
@@ -1,38 +1,53 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { DerivLogo } from "../Header/DerivLogo"; | ||
|
||
describe("DerivLogo Components", () => { | ||
it("redirects to 'https://deriv.com/'", () => { | ||
describe("DerivLogo Component", () => { | ||
it("renders default logo with correct size", () => { | ||
render(<DerivLogo />); | ||
const logo = screen.getByRole("img"); | ||
|
||
expect(logo).toBeInTheDocument(); | ||
expect(logo).toHaveAttribute("width", "48.22"); | ||
expect(logo).toHaveAttribute("height", "16"); | ||
}); | ||
|
||
it("renders wallets logo with correct size", () => { | ||
render(<DerivLogo variant="wallets" />); | ||
const logo = screen.getByRole("img"); | ||
|
||
expect(logo).toBeInTheDocument(); | ||
expect(logo).toHaveAttribute("width", "24"); | ||
expect(logo).toHaveAttribute("height", "24"); | ||
}); | ||
|
||
it("redirects to 'https://deriv.com/'", () => { | ||
render(<DerivLogo href="https://deriv.com/" />); | ||
expect(screen.getByRole("link")).toHaveAttribute( | ||
"href", | ||
"https://deriv.com/", | ||
); | ||
}); | ||
|
||
it("opens the link in new tab", () => { | ||
render(<DerivLogo />); | ||
render(<DerivLogo href="https://deriv.com/" target="_blank" />); | ||
expect(screen.getByRole("link")).toHaveAttribute("target", "_blank"); | ||
}); | ||
|
||
it("renders default logo when variant is set to 'default'", () => { | ||
render(<DerivLogo />); | ||
expect(screen.getByText("deriv-logo")).toBeInTheDocument(); | ||
}); | ||
it("renders default logo with passed size", () => { | ||
render(<DerivLogo logoHeight={20} logoWidth={20} />); | ||
const logo = screen.getByRole("img"); | ||
|
||
it("renders wallets logo when variant is set to 'wallets'", () => { | ||
render(<DerivLogo variant="wallets" />); | ||
expect(screen.getByText("deriv-wallets-logo")).toBeInTheDocument(); | ||
expect(logo).toBeInTheDocument(); | ||
expect(logo).toHaveAttribute("width", "20"); | ||
expect(logo).toHaveAttribute("height", "20"); | ||
}); | ||
|
||
it("passes additional props to link element", () => { | ||
const testClassName = "test-class"; | ||
const testStyle = { color: "red" }; | ||
|
||
render(<DerivLogo className={testClassName} style={testStyle} />); | ||
it("renders wallets logo with passed size", () => { | ||
render(<DerivLogo variant="wallets" logoHeight={30} logoWidth={30} />); | ||
const logo = screen.getByRole("img"); | ||
|
||
const link = screen.getByRole("link"); | ||
expect(link).toHaveClass(testClassName); | ||
expect(link).toHaveStyle(testStyle); | ||
expect(logo).toBeInTheDocument(); | ||
expect(logo).toHaveAttribute("width", "30"); | ||
expect(logo).toHaveAttribute("height", "30"); | ||
}); | ||
}); |
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