Skip to content

Commit

Permalink
fix: add test coverage for Panel elevations
Browse files Browse the repository at this point in the history
  • Loading branch information
brettdorrans committed Sep 28, 2022
1 parent 5239654 commit 720c5c6
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/panel/Panel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'jest-styled-components';

import { ThemeProvider } from '../theme-provider';
import { Panel } from './index';
import { ElevationHeight } from '../elevated';

const setup = (panel: React.ReactElement) =>
render(<ThemeProvider>{panel}</ThemeProvider>);
Expand All @@ -28,3 +29,14 @@ test('it works loading', () => {
const { container } = setup(<Panel loading>Hello world</Panel>);
expect(container.firstChild).toMatchSnapshot();
});

test('it works with elevation', () => {
const elevations: ElevationHeight[] = ['1', '2', '3', '4'];

elevations.forEach((elevation) => {
const { container } = setup(
<Panel elevation={elevation}>Hello world</Panel>
);
expect(container.firstChild).toMatchSnapshot();
});
});
76 changes: 76 additions & 0 deletions src/components/panel/__snapshots__/Panel.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,82 @@ exports[`it works loading 1`] = `
</div>
`;

exports[`it works with elevation 1`] = `
.c0 {
border-radius: 0.3rem;
box-shadow: 0 2px 3px rgba(0,0,0,0.1);
min-height: 8rem;
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
background-color: white;
}
<div
class="c0"
>
Hello world
</div>
`;

exports[`it works with elevation 2`] = `
.c0 {
border-radius: 0.3rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.12),0 10px 13px rgba(0,0,0,0.02),0 -10px 13px rgba(0,0,0,0.02);
min-height: 8rem;
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
background-color: white;
}
<div
class="c0"
>
Hello world
</div>
`;

exports[`it works with elevation 3`] = `
.c0 {
border-radius: 0.3rem;
box-shadow: 0 2px 5px rgba(0,0,0,0.16),-10px 15px 15px rgba(0,0,0,0.03),10px 0px 15px rgba(0,0,0,0.03);
min-height: 8rem;
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
background-color: white;
}
<div
class="c0"
>
Hello world
</div>
`;

exports[`it works with elevation 4`] = `
.c0 {
border-radius: 0.3rem;
box-shadow: 0 2px 6px rgba(0,0,0,0.18),-15px 20px 20px rgba(0,0,0,0.04),15px -5px 20px rgba(0,0,0,0.04);
min-height: 8rem;
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
background-color: white;
}
<div
class="c0"
>
Hello world
</div>
`;

exports[`it works with heading 1`] = `
.c0 {
border-radius: 0.3rem;
Expand Down

0 comments on commit 720c5c6

Please sign in to comment.