summaryrefslogtreecommitdiffstats
path: root/src/components/organisms/widgets/image-widget.test.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-04-15 22:56:36 +0200
committerArmand Philippot <git@armandphilippot.com>2022-04-15 22:56:36 +0200
commitd8a5c90ef58fa451c19e8d9e0aab0c493a0a6a9f (patch)
treefed069c73e14d5474566804a6a9d830d8316b038 /src/components/organisms/widgets/image-widget.test.tsx
parentedea15c845b33848b7b4f63616841e675b74d572 (diff)
chore: add an ImageWidget component
Diffstat (limited to 'src/components/organisms/widgets/image-widget.test.tsx')
-rw-r--r--src/components/organisms/widgets/image-widget.test.tsx54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/components/organisms/widgets/image-widget.test.tsx b/src/components/organisms/widgets/image-widget.test.tsx
new file mode 100644
index 0000000..8c24bd9
--- /dev/null
+++ b/src/components/organisms/widgets/image-widget.test.tsx
@@ -0,0 +1,54 @@
+import { render, screen } from '@test-utils';
+import ImageWidget from './image-widget';
+
+const description = 'Ut vitae sit';
+
+const img = {
+ alt: 'Et perferendis quaerat',
+ height: 480,
+ src: 'http://placeimg.com/640/480/nature',
+ width: 640,
+};
+
+const title = 'Fugiat cumque et';
+const titleLevel = 2;
+
+const url = '/another-page';
+
+describe('ImageWidget', () => {
+ it('renders an image', () => {
+ render(
+ <ImageWidget expanded={true} img={img} title={title} level={titleLevel} />
+ );
+ expect(screen.getByRole('img', { name: img.alt })).toBeInTheDocument();
+ });
+
+ it('renders a link', () => {
+ render(
+ <ImageWidget
+ expanded={true}
+ img={img}
+ title={title}
+ level={titleLevel}
+ url={url}
+ />
+ );
+ expect(screen.getByRole('link', { name: img.alt })).toHaveAttribute(
+ 'href',
+ url
+ );
+ });
+
+ it('renders a description', () => {
+ render(
+ <ImageWidget
+ expanded={true}
+ img={img}
+ description={description}
+ title={title}
+ level={titleLevel}
+ />
+ );
+ expect(screen.getByText(description)).toBeInTheDocument();
+ });
+});