open-nomad/ui/tests/integration/helpers/conditionally-capitalize-test.js
Phil Renaud 281f6a6fba
[ui] Make the not-auth'd messages in the app less token-centric (#15557)
* Make the not-auth'd messages in the app less token-centric

* new helper to conditionally capitalize handlebars strings
2022-12-20 11:02:44 -05:00

36 lines
1.5 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Helper | conditionally-capitalize', function (hooks) {
setupRenderingTest(hooks);
test('it capizalizes words correctly with a boolean condition', async function (assert) {
this.set('condition', true);
await render(hbs`{{conditionally-capitalize "tester" this.condition}}`);
assert.dom(this.element).hasText('Tester');
this.set('condition', false);
await render(hbs`{{conditionally-capitalize "tester" this.condition}}`);
assert.dom(this.element).hasText('tester');
});
test('it capizalizes words correctly with an existence condition', async function (assert) {
this.set('condition', {});
await render(hbs`{{conditionally-capitalize "tester" this.condition}}`);
assert.dom(this.element).hasText('Tester');
this.set('condition', null);
await render(hbs`{{conditionally-capitalize "tester" this.condition}}`);
assert.dom(this.element).hasText('tester');
});
test('it capizalizes words correctly with an numeric condition', async function (assert) {
this.set('condition', 1);
await render(hbs`{{conditionally-capitalize "tester" this.condition}}`);
assert.dom(this.element).hasText('Tester');
this.set('condition', 0);
await render(hbs`{{conditionally-capitalize "tester" this.condition}}`);
assert.dom(this.element).hasText('tester');
});
});