From a4002b262b1f771bec6b7c0e63e5329ddc400cce Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 31 Aug 2018 18:34:00 +0200 Subject: [PATCH] Keep time! --- package-lock.json | 6 ++++++ package.json | 1 + .../stream/test/__snapshots__/postComment.spec.tsx.snap | 6 +++--- src/core/client/stream/test/postComment.spec.tsx | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25c60ef44..cca10df6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index f48dcff66..13bc586c8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap index 69d6009dd..cb4c00a5c 100644 --- a/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap @@ -194,10 +194,10 @@ exports[`post a comment 1`] = `
{ .findByProps({ inputId: "comments-postCommentForm-field" }) .props.onChange({ html: "Hello world!" }); + 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();