forked from 4GeeksAcademy/react-tutorial-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
35 lines (31 loc) · 953 Bytes
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import ReactDOM from "react-dom";
import { WhatToRender } from "./app.jsx";
import jsxToString from "jsx-to-string";
import renderer from "react-test-renderer";
jest.mock("react-dom", () => ({ render: jest.fn() }));
test("ReactDOM needs to be called once", () => {
expect(ReactDOM.render.mock.calls.length).toBe(1);
});
test("The component Alert should return the exact HTML", () => {
const tree = renderer.create(ReactDOM.render.mock.calls[0][0]).toJSON();
expect(tree).toMatchInlineSnapshot(`
<div>
<div
className="alert alert-danger"
role="alert"
>
OMG! Something really bad has happended!
</div>
<div
className="alert alert-warning"
role="alert"
>
Well, it is not that bad after all!
</div>
</div>
`);
});
// test("The component should return return the exact HTML", () => {
// const tree = renderer.create(ReactDOM.render.mock.calls[0][0]).toJSON();
// expect(tree).toMatchInlineSnapshot();
// });