mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +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>
44 lines
1.8 KiB
JavaScript
44 lines
1.8 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 } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import { GENERAL } from 'vault/tests/helpers/general-selectors';
|
|
|
|
module('Integration | Component | UnsavedChangesModal', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.unsavedChanges = this.owner.lookup('service:unsavedChanges');
|
|
this.unsavedChanges.showModal = true;
|
|
const initialState = { title: 'Title 1', description: 'Old description' };
|
|
const currentState = { title: 'Title 1', description: 'New description' };
|
|
this.unsavedChanges.initialState = initialState;
|
|
this.unsavedChanges.currentState = currentState;
|
|
this.save = () => 'saved!';
|
|
this.discard = () => 'discarded!';
|
|
});
|
|
|
|
test('it shows unsaved changes modal', async function (assert) {
|
|
await render(hbs`<UnsavedChangesModal @onSave={{this.save}} @onDiscard={{this.discard}} />`);
|
|
assert.dom(GENERAL.modal.header('unsaved-changes')).hasText('Unsaved changes');
|
|
assert
|
|
.dom(GENERAL.modal.body('unsaved-changes'))
|
|
.hasText(`You've made changes to the following: Description Would you like to apply them?`);
|
|
});
|
|
|
|
test('it shows unsaved changes modal with custom changedFields', async function (assert) {
|
|
await render(
|
|
hbs`<UnsavedChangesModal @onSave={{this.save}} @onDiscard={{this.discard}} @changedFields={{this.changedFields}}/>`
|
|
);
|
|
assert.dom(GENERAL.modal.header('unsaved-changes')).hasText('Unsaved changes');
|
|
assert
|
|
.dom(GENERAL.modal.body('unsaved-changes'))
|
|
.hasText(`You've made changes to the following: Description Would you like to apply them?`);
|
|
});
|
|
});
|