Files
threshold-ui/ui/desktop/tests/integration/components/hidden-secret-test.js
T
hashicorp-copywrite[bot]andCameron Perera 3d610427d0 [COMPLIANCE] Add Copyright and License Headers (#1617)
* [COMPLIANCE] Add Copyright and License Headers

* chore: 🤖 update Copyright headers to satisfy our lint rules

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-03-01 09:39:41 -06:00

52 lines
1.4 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { hbs } from 'ember-cli-htmlbars';
import { setupIntl } from 'ember-intl/test-support';
module('Integration | Component | hidden-secret', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);
setupMirage(hooks);
// Global Secret for mocking
this.secret = `{
"secret_key": "QWERTYUIOP",
"secret_access_key": "QWERT.YUIOP234567890",
"nested_secret": {
"session_token": "ZXCVBNMLKJHGFDSAQWERTYUIOP0987654321",
"complex_nest": {
"hash": "qazxswedcvfrtgbnjhyujm.1234567890"
}
}
}`;
async function renderComponent() {
return render(hbs`
<HiddenSecret
@secret={{this.secret}}
/>
`);
}
test('it renders with a secret', async function (assert) {
assert.expect(1);
await renderComponent();
assert
.dom('.hidden-secret > span > span')
.hasText('■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■');
});
test('it reveals secret when button is clicked', async function (assert) {
assert.expect(1);
await renderComponent();
await click('.hidden-secret > button');
assert.dom('.hidden-secret > span > span').hasText(this.secret);
});
});