fix: 🐛 fix broken relative datetime live render tests (#1469)
This commit is contained in:
1 parent
e0f9b8723b
commit
bdc36b1e59
1 file changed
+18
-10
@@ -6,40 +6,48 @@ import { hbs } from 'ember-cli-htmlbars';
|
||||
module('Integration | Helper | relative-datetime-live', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
let now;
|
||||
|
||||
test('it renders relative date in "time" ago format', async function (assert) {
|
||||
assert.expect(8);
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
this.date = now - 30 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now - 100 - 30 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('30 seconds ago');
|
||||
|
||||
this.date = now - 30 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now - 1000 - 30 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('30 minutes ago');
|
||||
|
||||
this.date = now - 23 * 60 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now - 1000 - 23 * 60 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('23 hours ago');
|
||||
|
||||
this.date = now - 23 * 24 * 60 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now - 1000 - 23 * 24 * 60 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('23 days ago');
|
||||
|
||||
this.date = now - 8 * 31 * 24 * 60 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now - 1000 - 8 * 31 * 24 * 60 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('8 months ago');
|
||||
|
||||
this.date = now - 23 * 12 * 31 * 24 * 60 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now - 1000 - 23 * 12 * 31 * 24 * 60 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('23 years ago');
|
||||
|
||||
this.date = now + 8 * 30 * 24 * 60 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now + 7 * 31 * 24 * 60 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('in 7 months');
|
||||
|
||||
this.date = now + 23 * 12 * 31 * 24 * 60 * 60 * 1000;
|
||||
now = Date.now();
|
||||
this.date = now + 1000 + 22 * 12 * 31 * 24 * 60 * 60 * 1000;
|
||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||
assert.dom(this.element).hasText('in 22 years');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user