mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 11:07:00 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
75 lines
2.3 KiB
JavaScript
75 lines
2.3 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { click, render } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
module('Integration | Component | radio-button', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('it should spread attributes on input element', async function (assert) {
|
|
await render(
|
|
hbs(`
|
|
<RadioButton
|
|
id="foo"
|
|
name="bar"
|
|
class="radio"
|
|
@onChange={{fn (mut this.groupValue)}}
|
|
/>
|
|
`)
|
|
);
|
|
assert.dom('input').hasAttribute('id', 'foo', 'id set on input element');
|
|
assert.dom('input').hasAttribute('name', 'bar', 'name set on input element');
|
|
assert.dom('input').hasClass('radio', 'class set on input element');
|
|
});
|
|
|
|
test('it should be checked when value and groupValue are equal', async function (assert) {
|
|
await render(
|
|
hbs(`
|
|
<RadioButton
|
|
@value="foo"
|
|
@groupValue="foo"
|
|
@onChange={{fn (mut this.groupValue)}}
|
|
/>
|
|
`)
|
|
);
|
|
assert.true(
|
|
this.element.querySelector('input').checked,
|
|
'input is checked when value matches groupValue'
|
|
);
|
|
});
|
|
|
|
test('it should send onChange action and mark correct radio as checked', async function (assert) {
|
|
await render(
|
|
hbs(`
|
|
<RadioButton
|
|
@value="foo"
|
|
@groupValue={{this.groupValue}}
|
|
@onChange={{fn (mut this.groupValue)}}
|
|
data-test-radio-1
|
|
/>
|
|
<RadioButton
|
|
@value="bar"
|
|
@groupValue={{this.groupValue}}
|
|
@onChange={{fn (mut this.groupValue)}}
|
|
data-test-radio-2
|
|
/>
|
|
`)
|
|
);
|
|
const radio1 = this.element.querySelector('[data-test-radio-1]');
|
|
const radio2 = this.element.querySelector('[data-test-radio-2]');
|
|
assert.false(radio1.checked, 'radio1 is unchecked when groupValue is undefined');
|
|
assert.false(radio2.checked, 'radio2 is unchecked when groupValue is undefined');
|
|
await click('[data-test-radio-1]');
|
|
assert.true(radio1.checked, 'radio1 is checked');
|
|
assert.false(radio2.checked, 'radio2 is unchecked');
|
|
await click('[data-test-radio-2]');
|
|
assert.false(radio1.checked, 'radio1 is unchecked');
|
|
assert.true(radio2.checked, 'radio2 is checked');
|
|
});
|
|
});
|