mirror of
https://github.com/hashicorp/vault.git
synced 2026-04-04 05:12:19 +02:00
* Initial ts updgrade * Migrate linked-block to ts to squash ts errors * [VAULT-43339] 2/2 Update vault-reporting and add ember-intl (#13062) * Update vault-reporting and add ember-intl * Add setupIntl for rendering tests Co-authored-by: Jim Wright <jim.wright@hashicorp.com>
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'vault/tests/helpers';
|
|
import { render, click } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
module('Integration | Component | toggle-button', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('toggle functionality', async function (assert) {
|
|
await render(hbs`
|
|
<ToggleButton
|
|
@isOpen={{this.isOpen}}
|
|
@openLabel={{this.openLabel}}
|
|
@closedLabel={{this.closedLabel}}
|
|
@onClick={{fn (mut this.isOpen)}}
|
|
data-test-toggle-button
|
|
/>
|
|
`);
|
|
|
|
assert.dom('button').hasText('More options', 'renders default closedLabel');
|
|
await click('button');
|
|
assert.true(this.isOpen, 'it updates the value on click');
|
|
assert.dom('button').hasText('Hide options', 'renders default openLabel');
|
|
await click('button');
|
|
assert.false(this.isOpen, 'it updates the value on click');
|
|
|
|
this.setProperties({
|
|
openLabel: 'Close the options!',
|
|
closedLabel: 'Open the options!',
|
|
});
|
|
|
|
assert.dom('button').hasText('Open the options!', 'renders passed closedLabel');
|
|
await click('button');
|
|
assert.dom('button').hasText('Close the options!', 'renders passed openLabel');
|
|
assert
|
|
.dom('button')
|
|
.hasAttribute('data-test-toggle-button', '', 'Attributes are spread on the button element');
|
|
});
|
|
});
|