github.com/hernad/nomad@v1.6.112/ui/tests/integration/helpers/conditionally-capitalize-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 { setupRenderingTest } from 'ember-qunit'; 8 import { render } from '@ember/test-helpers'; 9 import { hbs } from 'ember-cli-htmlbars'; 10 11 module('Integration | Helper | conditionally-capitalize', function (hooks) { 12 setupRenderingTest(hooks); 13 14 test('it capizalizes words correctly with a boolean condition', async function (assert) { 15 this.set('condition', true); 16 await render(hbs`{{conditionally-capitalize "tester" this.condition}}`); 17 assert.dom(this.element).hasText('Tester'); 18 this.set('condition', false); 19 await render(hbs`{{conditionally-capitalize "tester" this.condition}}`); 20 assert.dom(this.element).hasText('tester'); 21 }); 22 23 test('it capizalizes words correctly with an existence condition', async function (assert) { 24 this.set('condition', {}); 25 await render(hbs`{{conditionally-capitalize "tester" this.condition}}`); 26 assert.dom(this.element).hasText('Tester'); 27 this.set('condition', null); 28 await render(hbs`{{conditionally-capitalize "tester" this.condition}}`); 29 assert.dom(this.element).hasText('tester'); 30 }); 31 32 test('it capizalizes words correctly with an numeric condition', async function (assert) { 33 this.set('condition', 1); 34 await render(hbs`{{conditionally-capitalize "tester" this.condition}}`); 35 assert.dom(this.element).hasText('Tester'); 36 this.set('condition', 0); 37 await render(hbs`{{conditionally-capitalize "tester" this.condition}}`); 38 assert.dom(this.element).hasText('tester'); 39 }); 40 });