Better tests

This commit is contained in:
Chi Vinh Le
2018-09-05 22:24:18 +02:00
parent 441cc9d57b
commit 90a875f40e
7 changed files with 13 additions and 10 deletions
@@ -27,6 +27,7 @@ function createTestRenderer(initialView: string): ReactTestRenderer {
sessionStorage: createInMemoryStorage(),
rest: new RestClient("http://localhost/api"),
postMessage: new PostMessageService(),
browserInfo: { ios: false },
};
return TestRenderer.create(
<TalkContextProvider value={context}>
@@ -37,6 +37,7 @@ beforeEach(() => {
sessionStorage: createInMemoryStorage(),
rest: new RestClient("http://localhost/api"),
postMessage: new PostMessageService(),
browserInfo: { ios: false },
};
testRenderer = TestRenderer.create(
@@ -37,6 +37,7 @@ beforeEach(() => {
sessionStorage: createInMemoryStorage(),
rest: new RestClient("http://localhost/api"),
postMessage: new PostMessageService(),
browserInfo: { ios: false },
};
testRenderer = TestRenderer.create(
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`post a comment 1`] = `
exports[`post a comment: optimistic response 1`] = `
<div
className="Flex-root App-root Flex-flex Flex-justifyCenter"
>
@@ -341,7 +341,7 @@ exports[`post a comment 1`] = `
</div>
`;
exports[`post a comment 2`] = `
exports[`post a comment: server response 1`] = `
<div
className="Flex-root App-root Flex-flex Flex-justifyCenter"
>
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`post a reply 1`] = `
exports[`post a reply: open reply form 1`] = `
<div
className="Flex-root App-root Flex-flex Flex-justifyCenter"
>
@@ -420,7 +420,7 @@ exports[`post a reply 1`] = `
</div>
`;
exports[`post a reply 2`] = `
exports[`post a reply: optimistic response 1`] = `
<div
className="Flex-root App-root Flex-flex Flex-justifyCenter"
>
@@ -893,7 +893,7 @@ exports[`post a reply 2`] = `
</div>
`;
exports[`post a reply 3`] = `
exports[`post a reply: server response 1`] = `
<div
className="Flex-root App-root Flex-flex Flex-justifyCenter"
>
@@ -88,11 +88,11 @@ it("post a comment", async () => {
timekeeper.reset();
// Test optimistic response.
expect(testRenderer.toJSON()).toMatchSnapshot();
expect(testRenderer.toJSON()).toMatchSnapshot("optimistic response");
// Wait for loading.
await timeout();
// Test after server response.
expect(testRenderer.toJSON()).toMatchSnapshot();
expect(testRenderer.toJSON()).toMatchSnapshot("server response");
});
@@ -86,7 +86,7 @@ it("post a reply", async () => {
.props.onClick();
await timeout();
expect(testRenderer.toJSON()).toMatchSnapshot();
expect(testRenderer.toJSON()).toMatchSnapshot("open reply form");
// Write reply .
testRenderer.root
@@ -98,12 +98,12 @@ it("post a reply", async () => {
.findByProps({ id: "comments-replyCommentForm-form-comment-0" })
.props.onSubmit();
// Test optimistic response.
expect(testRenderer.toJSON()).toMatchSnapshot();
expect(testRenderer.toJSON()).toMatchSnapshot("optimistic response");
timekeeper.reset();
// Wait for loading.
await timeout();
// Test after server response.
expect(testRenderer.toJSON()).toMatchSnapshot();
expect(testRenderer.toJSON()).toMatchSnapshot("server response");
});