forked from 4GeeksAcademy/react-tutorial-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
35 lines (29 loc) · 892 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 content from "./app.jsx";
import renderer from "react-test-renderer";
const fs = require('fs');
const path = require('path');
const app_content = fs.readFileSync(path.resolve(__dirname, './app.jsx'), 'utf8');
jest.mock("react-dom", () => ({ render: jest.fn() }));
test("ReactDOM.render needs to be called once", () => {
expect(ReactDOM.render.mock.calls.length).toBe(1);
});
test("The component should return LITERALLY what was asked", () => {
const tree = renderer.create(ReactDOM.render.mock.calls[0][0]).toJSON();
expect(tree).toMatchInlineSnapshot(`
<div>
<h1>
My name is
Bob
</h1>
<h2>
My last name is
Dylan
</h2>
</div>
`);
});
test("You should use the values of the customer object", () => {
expect(app_content).toMatch("customer.first_name");
expect(app_content).toMatch("customer.last_name");
})