github.com/hernad/nomad@v1.6.112/ui/tests/unit/components/gauge-chart-test.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import { module, test } from 'qunit'; 7 import { setupTest } from 'ember-qunit'; 8 9 module('Unit | Component | gauge-chart', function (hooks) { 10 setupTest(hooks); 11 12 hooks.beforeEach(function () { 13 this.subject = this.owner.factoryFor('component:gauge-chart'); 14 }); 15 16 test('percent is a function of value and total OR complement', function (assert) { 17 const chart = this.subject.create(); 18 chart.setProperties({ 19 value: 5, 20 total: 10, 21 }); 22 23 assert.equal(chart.percent, 0.5); 24 25 chart.setProperties({ 26 total: null, 27 complement: 15, 28 }); 29 30 assert.equal(chart.percent, 0.25); 31 }); 32 });