mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FEATURE: Decorate topic-level bookmark button with reminder time (#9426)
* Show the correct bookmark with clock icon when topic-level bookmark reminder time is set and show the time of the reminder in the title on hover. * Add a new bookmark lib and reminder time formatting function to show time with today/tomorrow shorthand for readability. E.g. tomorrow at 8:00am instead of Apr 16 2020 at 8:00am. This only applies to today + tomorrow, future dates are still treated the same.
This commit is contained in:
51
test/javascripts/lib/bookmark-test.js
Normal file
51
test/javascripts/lib/bookmark-test.js
Normal file
@ -0,0 +1,51 @@
|
||||
import { formattedReminderTime } from "discourse/lib/bookmark";
|
||||
|
||||
QUnit.module("lib:bookmark", {
|
||||
beforeEach() {
|
||||
// set the current now time for all tests
|
||||
let now = moment.tz("2020-04-11 08:00:00", "Australia/Brisbane");
|
||||
sandbox.useFakeTimers(now.valueOf());
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user