DEV: Upgrade sinon and fix time based bookmark tests (#9647)
Update sinon.js to 9.0.2 to access async fake timers https://sinonjs.org/releases/v9.0.2/fake-timers/ which can then be used with acceptance tests (previously useFakeTimers didn't work with await, e.g. for visit). Fix the bookmark acceptance test that was time based to use these new fake timers. Add a fakeTime function that uses moment and the provided date string + timezone to freeze time using useFakeTimers and return a clock. Add a timeStep function that accepts a clock from fakeTime and a function to run. Once the function is run we call clock.tickAsync(1000) to progress the fake clock forward 1s to progress promises/callbacks.
This commit is contained in:
@@ -2,6 +2,7 @@ import { logIn } from "helpers/qunit-helpers";
|
||||
import User from "discourse/models/user";
|
||||
import KeyboardShortcutInitializer from "discourse/initializers/keyboard-shortcuts";
|
||||
import { REMINDER_TYPES } from "discourse/lib/bookmark";
|
||||
import { fakeTime } from "helpers/qunit-helpers";
|
||||
let BookmarkController;
|
||||
|
||||
moduleFor("controller:bookmark", {
|
||||
@@ -18,8 +19,7 @@ moduleFor("controller:bookmark", {
|
||||
});
|
||||
|
||||
function mockMomentTz(dateString) {
|
||||
let now = moment.tz(dateString, BookmarkController.userTimezone);
|
||||
sandbox.useFakeTimers(now.valueOf());
|
||||
fakeTime(dateString, BookmarkController.userTimezone);
|
||||
}
|
||||
|
||||
QUnit.test("showLaterToday when later today is tomorrow do not show", function(
|
||||
|
||||
Reference in New Issue
Block a user