-
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.
- Loading branch information
1 parent
9b4fa62
commit 464e901
Showing
3 changed files
with
55 additions
and
1 deletion.
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,28 @@ | ||
import { render } from "@testing-library/react"; | ||
import Image from "../Image"; | ||
|
||
describe("Image", () => { | ||
const altText = "Alt Text"; | ||
it("should not render if the url is not provided", () => { | ||
const { queryByAltText } = render(<Image alternativeText={altText} />); | ||
expect(queryByAltText(altText)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should render an image as an <img> tag", () => { | ||
const { getByAltText } = render( | ||
<Image url="photo.jpg" alternativeText={altText} />, | ||
); | ||
const image = getByAltText(altText); | ||
expect(image).toBeInTheDocument(); | ||
expect(image).toBeInstanceOf(HTMLImageElement); | ||
}); | ||
|
||
it("should render an svg image inline instead of as an <img> tag", () => { | ||
const { queryByAltText } = render( | ||
<Image url="image.svg" alternativeText={altText} ext=".svg" />, | ||
); | ||
// since react-inlinesvg parses an actual svg to create the DOM, | ||
// we basically just need to ensure that an <img> isn't present | ||
expect(queryByAltText(altText)).not.toBeInTheDocument(); | ||
}); | ||
}); |
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