-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement initial snapshot tests for existing components
This commit implements the first snapshot tests for all existing components. The snapshots approach has been chosen by purpose because all components are in initial implementation state and actually only render a React `<Fragment>`. It also fixes the resulting problems with `propType` violations for the `Landing` (index/root) page which renders the `Root` component without passing children. This has been fixed by using a `React.Fragment`. GH-39
- Loading branch information
1 parent
dba8c65
commit fe7278e
Showing
5 changed files
with
52 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
import React from "react"; | ||
import React, { Fragment } from "react"; | ||
|
||
import Root from "containers/core/Root"; | ||
|
||
|
@@ -17,6 +17,10 @@ import Root from "containers/core/Root"; | |
* @author Sven Greb <[email protected]> | ||
* @since 0.1.0 | ||
*/ | ||
const Landing = () => <Root />; | ||
const Landing = () => ( | ||
<Root> | ||
<Fragment /> | ||
</Root> | ||
); | ||
|
||
export default Landing; |
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,22 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
import React, { Fragment } from "react"; | ||
import { render } from "react-testing-library"; | ||
|
||
import Root from "containers/core/Root"; | ||
|
||
test("snapshot", () => { | ||
const { container } = render( | ||
<Root> | ||
<Fragment /> | ||
</Root> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/components/containers/core/Root/__snapshots__/Root.test.jsx.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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`snapshot 1`] = `<div />`; |
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`snapshot 1`] = `<div />`; |
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,18 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
import React from "react"; | ||
import { render } from "react-testing-library"; | ||
|
||
import Landing from "pages"; | ||
|
||
test("snapshot", () => { | ||
const { container } = render(<Landing />); | ||
expect(container).toMatchSnapshot(); | ||
}); |