Files
threshold-ui/ui/admin/tests/integration/components/info-field-test.js
T

49 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2022-11-30 14:38:12 -05:00
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | info-field', function (hooks) {
setupRenderingTest(hooks);
2023-11-10 11:21:52 -05:00
hooks.beforeEach(function () {
this.set('label', 'Type');
this.set('helperText', 'Description');
});
2022-11-30 14:38:12 -05:00
test('it renders without icon', async function (assert) {
await render(
hbs`
2022-12-13 15:49:22 -05:00
<InfoField @value="JSON" as |F|>
2023-11-10 11:21:52 -05:00
<F.Label>{{this.label}}</F.Label>
<F.HelperText>{{this.helperText}}</F.HelperText>
2022-11-30 14:38:12 -05:00
</InfoField>
2023-11-10 11:21:52 -05:00
`,
2022-11-30 14:38:12 -05:00
);
assert.dom('.info-field').isVisible();
assert.dom('.info-field .hds-form-label').hasText('Type');
2022-12-13 15:49:22 -05:00
assert.dom('.info-field .hds-form-helper-text').hasText('Description');
2022-11-30 14:38:12 -05:00
assert.dom('.info-field .hds-form-text-input').isVisible();
});
test('it renders with icon', async function (assert) {
await render(
hbs`
2022-12-13 15:49:22 -05:00
<InfoField @value="JSON" @icon='apple' as |F|>
2023-11-10 11:21:52 -05:00
<F.Label>{{this.label}}</F.Label>
<F.HelperText>{{this.helperText}}</F.HelperText>
2022-11-30 14:38:12 -05:00
</InfoField>
2023-11-10 11:21:52 -05:00
`,
2022-11-30 14:38:12 -05:00
);
assert.dom('.info-field').isVisible();
assert.dom('.info-field .hds-form-label').hasText('Type');
assert.dom('.info-field .hds-form-helper-text').hasText('Description');
2022-11-30 14:38:12 -05:00
assert.dom('[data-test-icon="apple"]').isVisible();
assert.dom('.info-field .hds-form-text-input').isVisible();
});
});