forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jest for front-end component testing (metabase#4165)
* jest setup and simple tests for Button * add jest to CI * cleanup * make eslint play nice
- Loading branch information
Showing
7 changed files
with
2,034 additions
and
1,084 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
import { render } from 'enzyme'; | ||
|
||
import Button from './Button'; | ||
|
||
describe('Button', () => { | ||
it('should render correctly', () => { | ||
const tree = renderer.create( | ||
<Button>Clickity click</Button> | ||
).toJSON(); | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) | ||
it('should render correctly with an icon', () => { | ||
const tree = renderer.create( | ||
<Button icon='star'> | ||
Clickity click | ||
</Button> | ||
).toJSON(); | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render a primary button given the primary prop', () => { | ||
const button = render( | ||
<Button primary> | ||
Clickity click | ||
</Button> | ||
) | ||
|
||
expect(button.find('button.Button--primary').length).toEqual(1) | ||
}) | ||
}) |
34 changes: 34 additions & 0 deletions
34
frontend/src/metabase/components/__snapshots__/Button.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
exports[`Button should render correctly 1`] = ` | ||
<button | ||
className="Button "> | ||
<div | ||
className="flex layout-centered"> | ||
<div> | ||
Clickity click | ||
</div> | ||
</div> | ||
</button> | ||
`; | ||
|
||
exports[`Button should render correctly with an icon 1`] = ` | ||
<button | ||
className="Button "> | ||
<div | ||
className="flex layout-centered"> | ||
<svg | ||
className="mr1" | ||
fill="currentcolor" | ||
height={14} | ||
name="star" | ||
size={14} | ||
viewBox="0 0 32 32" | ||
width={14}> | ||
<path | ||
d="M16 0 L21 11 L32 12 L23 19 L26 31 L16 25 L6 31 L9 19 L0 12 L11 11" /> | ||
</svg> | ||
<div> | ||
Clickity click | ||
</div> | ||
</div> | ||
</button> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.