2020-04-16 07:20:44 +08:00
|
|
|
import { formattedReminderTime } from "discourse/lib/bookmark";
|
2020-05-07 07:10:32 +08:00
|
|
|
import { fakeTime } from "helpers/qunit-helpers";
|
2020-04-16 07:20:44 +08:00
|
|
|
|
|
|
|
QUnit.module("lib:bookmark", {
|
|
|
|
beforeEach() {
|
2020-05-07 07:10:32 +08:00
|
|
|
fakeTime("2020-04-11 08:00:00", "Australia/Brisbane");
|
|
|
|
},
|
|
|
|
|
|
|
|
afterEach() {
|
|
|
|
sandbox.restore();
|
2020-04-16 07:20:44 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test(
|
|
|
|
"formattedReminderTime works when the reminder time is tomorrow",
|
|
|
|
assert => {
|
|
|
|
let reminderAt = "2020-04-12 09:45:00";
|
|
|
|
let reminderAtDate = moment
|
|
|
|
.tz(reminderAt, "Australia/Brisbane")
|
|
|
|
.format("H:mm a");
|
|
|
|
assert.equal(
|
|
|
|
formattedReminderTime(reminderAt, "Australia/Brisbane"),
|
|
|
|
"tomorrow at " + reminderAtDate
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
QUnit.test(
|
|
|
|
"formattedReminderTime works when the reminder time is today",
|
|
|
|
assert => {
|
|
|
|
let reminderAt = "2020-04-11 09:45:00";
|
|
|
|
let reminderAtDate = moment
|
|
|
|
.tz(reminderAt, "Australia/Brisbane")
|
|
|
|
.format("H:mm a");
|
|
|
|
assert.equal(
|
|
|
|
formattedReminderTime(reminderAt, "Australia/Brisbane"),
|
|
|
|
"today at " + reminderAtDate
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
QUnit.test(
|
|
|
|
"formattedReminderTime works when the reminder time is in the future",
|
|
|
|
assert => {
|
|
|
|
let reminderAt = "2020-04-15 09:45:00";
|
|
|
|
let reminderAtDate = moment
|
|
|
|
.tz(reminderAt, "Australia/Brisbane")
|
|
|
|
.format("H:mm a");
|
|
|
|
assert.equal(
|
|
|
|
formattedReminderTime(reminderAt, "Australia/Brisbane"),
|
|
|
|
"at Apr 15, 2020 " + reminderAtDate
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|