This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js
Robin Ward 23f24bfb51 REFACTOR: Move javascript tests inside discourse app
This is where they should be as far as ember is concerned. Note this is
a huge commit and we should be really careful everything continues to
work properly.
2020-10-02 11:29:36 -04:00

55 lines
1.4 KiB
JavaScript

import { formattedReminderTime } from "discourse/lib/bookmark";
import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
QUnit.module("lib:bookmark", {
beforeEach() {
fakeTime("2020-04-11 08:00:00", "Australia/Brisbane");
},
afterEach() {
sandbox.restore();
},
});
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
);
}
);