mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +02:00
* convert to typescript * move getOptions to namespace service * delete unneeded ts file * add test coverage and cleanup getOptions method * use new admin const Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'vault/tests/helpers';
|
|
import { click, render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import sinon from 'sinon';
|
|
|
|
module('Integration | Component | usage | Page::Usage', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(async function () {
|
|
this.authStub = sinon.stub(this.owner.lookup('service:auth'), 'authData');
|
|
this.api = this.owner.lookup('service:api');
|
|
this.generateUtilizationReportStub = sinon.stub(this.api.sys, 'generateUtilizationReport').resolves({});
|
|
});
|
|
|
|
hooks.afterEach(function () {
|
|
this.generateUtilizationReportStub.restore();
|
|
});
|
|
|
|
test('it provides the correct fetch function to the dashboard component', async function (assert) {
|
|
await render(hbs`<Usage::Page />`);
|
|
assert.true(this.generateUtilizationReportStub.calledOnce, 'fetch function is called on render');
|
|
});
|
|
|
|
test('it renders namespaces in dropdown', async function (assert) {
|
|
this.internalUiListNamespacesStub = sinon.stub(this.api.sys, 'internalUiListNamespaces');
|
|
this.internalUiListNamespacesStub.resolves({ keys: ['ns1', 'ns2'] });
|
|
|
|
await render(hbs`<Usage::Page />`);
|
|
await click('[data-test-vault-reporting-namespace-picker] button');
|
|
assert.dom('ul').hasText('root ns1 ns2');
|
|
this.internalUiListNamespacesStub.restore();
|
|
});
|
|
});
|