Skip to content

Commit 1ebbec7

Browse files
authored
Initial commit
1 parent a8b5404 commit 1ebbec7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/__tests__/integrations.tests.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from "react";
2+
import {mount} from "enzyme";
3+
import Root from "Root";
4+
import App from "components/App";
5+
import moxios from "moxios";
6+
7+
moxios.install();
8+
moxios.stubRequest('https://json-server-comment.herokuapp.com/comments', {
9+
status: 200,
10+
response: [
11+
{name: 'Fetched #1'},
12+
{name: 'Fetched #2'},
13+
{name: 'Fetched #3'}
14+
]
15+
})
16+
17+
afterEach(() => {
18+
moxios.uninstall();
19+
})
20+
21+
it('can fetch a list of comments and display them', (done) => {
22+
const wrapped = mount(
23+
<Root>
24+
<App/>
25+
</Root>
26+
)
27+
wrapped.find('.fetch-comments').simulate('click');
28+
moxios.wait(() => {
29+
wrapped.update();
30+
expect(wrapped.find('li').length).toEqual(3);
31+
done();
32+
wrapped.unmount();
33+
})
34+
})

0 commit comments

Comments
 (0)