Add duration unit format (#2483)

* chore: 🤖 add @formatjs/intl-durationformat to addons/core

* refactor: 💡 replace old duration format with new package

* chore: 🤖 remove intl-unofficial-duration-unit-format

* Add missing copyright headers

* test: 💍 add more test cases

---------

Co-authored-by: cameronperera <cameronperera@users.noreply.github.com>
This commit is contained in:
Cameron Pereraandcameronperera authored and GitHub committed 2024-09-13 09:43:08 -05:00
1 parent e395b1196c
commit 9648e1fa3b
8 files changed
+157 -24

No files matched your search

@@ -13,9 +13,7 @@ module('Integration | Helper | time-remaining', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks, 'en-us');
test('it calculates the correct time remaining', async function (assert) {
assert.expect(1);
test('it calculates the correct time remainin with less than 24 hours', async function (assert) {
this.set('expirationTime', new Date(Date.now() + 1000 * 60 * 60 * 24));
await render(hbs`{{time-remaining this.expirationTime}}`);
@@ -23,9 +21,29 @@ module('Integration | Helper | time-remaining', function (hooks) {
assert.strictEqual(this.element.textContent.trim(), '23:59:59 remaining');
});
test('it handles negative time remaining', async function (assert) {
assert.expect(1);
test('it calculates the correct time remaining with more than 24 hours', async function (assert) {
this.set('expirationTime', new Date(Date.now() + 1001 * 60 * 60 * 24));
await render(hbs`{{time-remaining this.expirationTime}}`);
assert.strictEqual(
this.element.textContent.trim(),
'1 day, 0:01:26 remaining',
);
});
test('it calculates the correct time remaining with more than a week', async function (assert) {
this.set('expirationTime', new Date(Date.now() + 1001 * 60 * 60 * 24 * 8));
await render(hbs`{{time-remaining this.expirationTime}}`);
assert.strictEqual(
this.element.textContent.trim(),
'1 wk, 1 day, 0:11:31 remaining',
);
});
test('it handles negative time remaining', async function (assert) {
this.set('expirationTime', new Date(Date.now() - 1000 * 60 * 60 * 24));
await render(hbs`{{time-remaining this.expirationTime}}`);