Skip to content

Added page and panel tests #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions __tests__/Page.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { shallow } from 'enzyme';
import React from 'react';
import Page from '@/components/Page';

describe('Page test', () => {
it('should render page', () => {
const container = shallow(
<Page>
Hello world
</Page>
);

expect(container.find('.page').length).toBe(1);
});

it('should render page content', () => {
const container = shallow(
<Page.Content>
Hello world
</Page.Content>
);

expect(container.find('.page-content').length).toBe(1);
});

it('should render page header', () => {
const container = shallow(
<Page.Header title="Test">
Hello world
</Page.Header>
);

expect(container.find('.page-header').length).toBe(1);
expect(container.find('.page-header > .page-header-title').length).toBe(1);
expect(container.find('.page-header > .page-header-title').text()).toContain('Test')
});
});
25 changes: 25 additions & 0 deletions __tests__/Panel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { shallow } from 'enzyme';
import React from 'react';
import Panel from '@/components/Panel';

describe('Page test', () => {
it('should render panel', () => {
const container = shallow(
<Panel>
Hello world
</Panel>
);

expect(container.find('.panel').length).toBe(1);
});

it('should render spaced panel', () => {
const container = shallow(
<Panel spaced>
Hello world
</Panel>
);

expect(container.find('.panel.panel-spaced').length).toBe(1);
});
});
2 changes: 1 addition & 1 deletion src/components/Page/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const PageHeader = ({
'page-header-title'
)}
>
<h1>{title}</h1>
{title}
</div>
)}
{children}
Expand Down
6 changes: 6 additions & 0 deletions src/style/components/_page.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "../base/mixins";

.page {
background: var(--page-background-color);

Expand All @@ -12,6 +14,10 @@
}

.page-header-title {
font-size: 2rem;
color: mixins.color('gray', 900);
font-weight: normal;
margin: 0;
padding-bottom: var(--page-gutter);
}
}
Expand Down