Keep time!

This commit is contained in:
Chi Vinh Le
2018-08-31 18:34:00 +02:00
parent 51e6d5b29e
commit a4002b262b
4 changed files with 13 additions and 3 deletions
+6
View File
@@ -23515,6 +23515,12 @@
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=",
"dev": true
},
"timekeeper": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/timekeeper/-/timekeeper-2.1.2.tgz",
"integrity": "sha512-fc1DDqbiyz5vxRO4xkiATwfWUw1FV7W20+FJYal1SnoIYgNuB4WNxYLtbG3zjUBwOSk3P4u1TgBAZYG/aqBWMw==",
"dev": true
},
"timers-browserify": {
"version": "2.0.10",
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz",
+1
View File
@@ -209,6 +209,7 @@
"simulant": "^0.2.2",
"sinon": "^6.1.5",
"style-loader": "^0.21.0",
"timekeeper": "^2.1.2",
"ts-jest": "^23.0.0",
"ts-loader": "^4.4.2",
"ts-node": "^6.2.0",
@@ -194,10 +194,10 @@ exports[`post a comment 1`] = `
</span>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-08-31T16:14:09.617Z"
title="2018-08-31T16:14:09.617Z"
dateTime="2018-07-06T18:24:00.002Z"
title="2018-07-06T18:24:00.002Z"
>
2018-08-31T16:14:09.617Z
2018-07-06T18:24:00.002Z
</time>
</div>
<div
@@ -1,6 +1,7 @@
import React from "react";
import TestRenderer, { ReactTestRenderer } from "react-test-renderer";
import { RecordProxy } from "relay-runtime";
import timekeeper from "timekeeper";
import { timeout } from "talk-common/utils";
import { TalkContext, TalkContextProvider } from "talk-framework/lib/bootstrap";
@@ -94,11 +95,13 @@ it("post a comment", async () => {
.findByProps({ inputId: "comments-postCommentForm-field" })
.props.onChange({ html: "<strong>Hello world!</strong>" });
timekeeper.travel(new Date("2018-07-06T18:24:00.000Z"));
testRenderer.root
.findByProps({ id: "comments-postCommentForm-form" })
.props.onSubmit();
// Test optimistic response.
expect(testRenderer.toJSON()).toMatchSnapshot();
timekeeper.reset();
// Wait for loading.
await timeout();