aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/branding/branding.test.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-09 16:31:00 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commit891441a76173c708c6604fa203b175aefa222333 (patch)
tree27295311bb01a4e44dcc4f68422975cd705a24b8 /src/components/molecules/branding/branding.test.tsx
parentf11a906420975e833f278a08470d8f9783c76f73 (diff)
refactor(components): rewrite Branding component
The component should only be responsible of the layout for the logo, the name and the optional baseline. Also, the homepage url could be different from `/` so the consumer should give the right url.
Diffstat (limited to 'src/components/molecules/branding/branding.test.tsx')
-rw-r--r--src/components/molecules/branding/branding.test.tsx77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/components/molecules/branding/branding.test.tsx b/src/components/molecules/branding/branding.test.tsx
new file mode 100644
index 0000000..7f41098
--- /dev/null
+++ b/src/components/molecules/branding/branding.test.tsx
@@ -0,0 +1,77 @@
+import { describe, expect, it } from '@jest/globals';
+import { render, screen as rtlScreen } from '@testing-library/react';
+import NextImage from 'next/image';
+import { Branding } from './branding';
+
+describe('Branding', () => {
+ it('renders the brand logo and name', () => {
+ const altText = 'dolorem aut ullam';
+ const name = 'ducimus quo enim';
+
+ render(
+ <Branding
+ logo={
+ <NextImage
+ alt={altText}
+ height={100}
+ src="https://picsum.photos/100"
+ width={100}
+ />
+ }
+ name={<div>{name}</div>}
+ />
+ );
+
+ expect(rtlScreen.getByRole('img', { name: altText })).toBeInTheDocument();
+ expect(rtlScreen.getByText(name)).toBeInTheDocument();
+ });
+
+ it('can render the brand logo, name and baseline', () => {
+ const altText = 'dolorem aut ullam';
+ const name = 'ducimus quo enim';
+ const baseline = 'ab consequatur est';
+
+ render(
+ <Branding
+ baseline={<div>{baseline}</div>}
+ logo={
+ <NextImage
+ alt={altText}
+ height={100}
+ src="https://picsum.photos/100"
+ width={100}
+ />
+ }
+ name={<div>{name}</div>}
+ />
+ );
+
+ expect(rtlScreen.getByRole('img', { name: altText })).toBeInTheDocument();
+ expect(rtlScreen.getByText(name)).toBeInTheDocument();
+ expect(rtlScreen.getByText(baseline)).toBeInTheDocument();
+ });
+
+ it('can render the brand name wrapped in a link', () => {
+ const altText = 'dolorem aut ullam';
+ const name = 'ducimus quo enim';
+ const url = '/velit';
+
+ render(
+ <Branding
+ logo={
+ <NextImage
+ alt={altText}
+ height={100}
+ src="https://picsum.photos/100"
+ width={100}
+ />
+ }
+ name={<div>{name}</div>}
+ url={url}
+ />
+ );
+
+ expect(rtlScreen.getByRole('img', { name: altText })).toBeInTheDocument();
+ expect(rtlScreen.getByRole('link', { name })).toHaveAttribute('href', url);
+ });
+});