aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/layout/branding.test.tsx
blob: cfb55c50e3a4c684478c446a9d8c6b81f8f685cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { describe, expect, it } from '@jest/globals';
import NextImage from 'next/image';
import { render, screen as rtlScreen } from '../../../../tests/utils';
import { Logo } from '../../atoms';
import { Branding } from './branding';

describe('Branding', () => {
  it('renders a photo', () => {
    const altText = 'A photo example';

    render(
      <Branding
        logo={<Logo />}
        photo={
          <NextImage
            alt="A photo example"
            height={200}
            src="https://picsum.photos/200"
            width={200}
          />
        }
        title="Website title"
      />
    );
    expect(rtlScreen.getByRole('img', { name: altText })).toBeInTheDocument();
  });

  it('renders a logo', () => {
    const logoHeading = 'sed enim voluptatem';

    render(
      <Branding
        logo={<Logo heading={logoHeading} />}
        photo={
          <NextImage
            alt="A photo example"
            height={200}
            src="https://picsum.photos/200"
            width={200}
          />
        }
        title="Website name"
      />
    );
    expect(rtlScreen.getByTitle(logoHeading)).toBeInTheDocument();
  });

  it('renders a baseline', () => {
    render(
      <Branding
        logo={<Logo />}
        photo={
          <NextImage
            alt="A photo example"
            height={200}
            src="https://picsum.photos/200"
            width={200}
          />
        }
        title="Website title"
        baseline="Website baseline"
      />
    );
    expect(rtlScreen.getByText('Website baseline')).toBeInTheDocument();
  });

  it('renders a title wrapped with h1 element', () => {
    render(
      <Branding
        logo={<Logo />}
        photo={
          <NextImage
            alt="A photo example"
            height={200}
            src="https://picsum.photos/200"
            width={200}
          />
        }
        title="Website title"
        isHome={true}
      />
    );
    expect(
      rtlScreen.getByRole('heading', { level: 1, name: 'Website title' })
    ).toBeInTheDocument();
  });

  it('renders a title with h1 styles', () => {
    render(
      <Branding
        logo={<Logo />}
        photo={
          <NextImage
            alt="A photo example"
            height={200}
            src="https://picsum.photos/200"
            width={200}
          />
        }
        title="Website title"
        isHome={false}
      />
    );
    expect(
      rtlScreen.queryByRole('heading', { level: 1, name: 'Website title' })
    ).not.toBeInTheDocument();
    expect(rtlScreen.getByText('Website title')).toHaveClass('heading--1');
  });
});