mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 17:16:27 +08:00
Better tests
This commit is contained in:
@@ -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");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user