import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; module('Integration | Helper | format-duration', function(hooks) { setupRenderingTest(hooks); test('it supports strings and formats seconds', async function(assert) { await render(hbs`
Date: {{format-duration '3606'}}
`); assert .dom('[data-test-format-duration]') .includesText('1 hour 6 seconds', 'it renders the duration in hours and seconds'); }); test('it is able to format seconds and days', async function(assert) { await render(hbs`Date: {{format-duration '93606000'}}
`); assert .dom('[data-test-format-duration]') .includesText( '2 years 11 months 18 days 9 hours 40 minutes', 'it renders with years months and days and hours and minutes' ); }); test('it is able to format numbers', async function(assert) { this.set('number', 60); await render(hbs`Date: {{format-duration number}}
`); assert .dom('[data-test-format-duration]') .includesText('1 minute', 'it renders duration when a number is passed in.'); }); });