diff --git a/addon/helpers/format-milliseconds.js b/addon/helpers/format-milliseconds.js new file mode 100644 index 0000000..01aef2a --- /dev/null +++ b/addon/helpers/format-milliseconds.js @@ -0,0 +1,9 @@ +import { helper } from '@ember/component/helper'; + +export default helper(function formatMilliseconds([milliseconds]) { + if (!milliseconds || typeof milliseconds !== 'number') { + return '-'; + } + + return milliseconds.toString().startsWith(0) ? `${milliseconds.toFixed(3).substring(2)}ms` : `${milliseconds.toFixed(3)}s`; +}); diff --git a/app/helpers/format-milliseconds.js b/app/helpers/format-milliseconds.js new file mode 100644 index 0000000..f41f62f --- /dev/null +++ b/app/helpers/format-milliseconds.js @@ -0,0 +1 @@ +export { default } from '@fleetbase/ember-ui/helpers/format-milliseconds'; diff --git a/tests/integration/helpers/format-milliseconds-test.js b/tests/integration/helpers/format-milliseconds-test.js new file mode 100644 index 0000000..1f94d70 --- /dev/null +++ b/tests/integration/helpers/format-milliseconds-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Helper | format-milliseconds', function (hooks) { + setupRenderingTest(hooks); + + // TODO: Replace this with your real tests. + test('it renders', async function (assert) { + this.set('inputValue', '1234'); + + await render(hbs`{{format-milliseconds this.inputValue}}`); + + assert.dom().hasText('1234'); + }); +}); diff --git a/tests/unit/services/dashboard-test.js b/tests/unit/services/dashboard-test.js index fc68934..3da6ac0 100644 --- a/tests/unit/services/dashboard-test.js +++ b/tests/unit/services/dashboard-test.js @@ -6,6 +6,12 @@ module('Unit | Service | dashboard', function (hooks) { // TODO: Replace this with your real tests. test('it exists', function (assert) { + // register dummy services + this.owner.register('service:store', {}, { instantiate: false }); + this.owner.register('service:fetch', {}, { instantiate: false }); + this.owner.register('service:notifications', {}, { instantiate: false }); + this.owner.register('service:intl', {}, { instantiate: false }); + this.owner.register('service:universe', {}, { instantiate: false }); let service = this.owner.lookup('service:dashboard'); assert.ok(service); });