vault/ui/tests/unit/adapters/application-test.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

34 lines
1.1 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { setupMirage } from 'ember-cli-mirage/test-support';
import { module, test } from 'qunit';
import Sinon from 'sinon';
import { setupTest } from 'vault/tests/helpers';
module('Unit | Adapter | application', function (hooks) {
setupTest(hooks);
setupMirage(hooks);
hooks.beforeEach(function () {
this.server.get('/some-url', function () {
return {
warnings: ['this is a warning'],
};
});
this.adapter = this.owner.lookup('adapter:application');
});
test('it triggers info flash message when warnings returned from API', async function (assert) {
const flashSuccessSpy = Sinon.spy(this.owner.lookup('service:flash-messages'), 'info');
await this.adapter.ajax('/v1/some-url', 'GET', { skipWarnings: true });
assert.true(flashSuccessSpy.notCalled, 'flash is not called when skipWarnings option passed');
await this.adapter.ajax('/v1/some-url', 'GET', {});
assert.true(flashSuccessSpy.calledOnce);
assert.true(flashSuccessSpy.calledWith('this is a warning'));
});
});