Skip to content

Commit 70eafb5

Browse files
authored
Merge pull request #7 from machielsdev/feature/page-tests
Added page and panel tests
2 parents f52c02b + 3c4ded9 commit 70eafb5

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

__tests__/Page.test.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { shallow } from 'enzyme';
2+
import React from 'react';
3+
import Page from '@/components/Page';
4+
5+
describe('Page test', () => {
6+
it('should render page', () => {
7+
const container = shallow(
8+
<Page>
9+
Hello world
10+
</Page>
11+
);
12+
13+
expect(container.find('.page').length).toBe(1);
14+
});
15+
16+
it('should render page content', () => {
17+
const container = shallow(
18+
<Page.Content>
19+
Hello world
20+
</Page.Content>
21+
);
22+
23+
expect(container.find('.page-content').length).toBe(1);
24+
});
25+
26+
it('should render page header', () => {
27+
const container = shallow(
28+
<Page.Header title="Test">
29+
Hello world
30+
</Page.Header>
31+
);
32+
33+
expect(container.find('.page-header').length).toBe(1);
34+
expect(container.find('.page-header > .page-header-title').length).toBe(1);
35+
expect(container.find('.page-header > .page-header-title').text()).toContain('Test')
36+
});
37+
});

__tests__/Panel.test.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { shallow } from 'enzyme';
2+
import React from 'react';
3+
import Panel from '@/components/Panel';
4+
5+
describe('Page test', () => {
6+
it('should render panel', () => {
7+
const container = shallow(
8+
<Panel>
9+
Hello world
10+
</Panel>
11+
);
12+
13+
expect(container.find('.panel').length).toBe(1);
14+
});
15+
16+
it('should render spaced panel', () => {
17+
const container = shallow(
18+
<Panel spaced>
19+
Hello world
20+
</Panel>
21+
);
22+
23+
expect(container.find('.panel.panel-spaced').length).toBe(1);
24+
});
25+
});

src/components/Page/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const PageHeader = ({
2424
'page-header-title'
2525
)}
2626
>
27-
<h1>{title}</h1>
27+
{title}
2828
</div>
2929
)}
3030
{children}

src/style/components/_page.scss

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "../base/mixins";
2+
13
.page {
24
background: var(--page-background-color);
35

@@ -12,6 +14,10 @@
1214
}
1315

1416
.page-header-title {
17+
font-size: 2rem;
18+
color: mixins.color('gray', 900);
19+
font-weight: normal;
20+
margin: 0;
1521
padding-bottom: var(--page-gutter);
1622
}
1723
}

0 commit comments

Comments
 (0)