Files
threshold-ui/ui/desktop/tests/unit/controllers/cluster-url-test.js
T
55e1e68f30 [COMPLIANCE] Update Copyright and License Headers (#3099)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Dharini <dharini@hashicorp.com>
2026-01-20 11:35:10 -05:00

47 lines
1.4 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { authenticateSession } from 'ember-simple-auth/test-support';
import { setupIntl } from 'ember-intl/test-support';
import WindowMockIPC from '../../helpers/window-mock-ipc';
module('Unit | Controller | cluster-url', function (hooks) {
setupTest(hooks);
setupIntl(hooks, 'en-us');
let controller;
let clusterUrl;
let mockIPC;
const setupMockIpc = (test) => {
test.owner.register('service:browser/window', WindowMockIPC);
mockIPC = test.owner.lookup('service:browser/window').mockIPC;
};
hooks.beforeEach(async function () {
await authenticateSession({});
controller = this.owner.lookup('controller:cluster-url');
clusterUrl = this.owner.lookup('service:cluster-url');
setupMockIpc(this);
});
test('it exists', function (assert) {
assert.ok(controller);
});
test('setClusterUrl action de-authenticates a user and resets cluster url', async function (assert) {
const newClusterUrl = 'http://localhost:9200';
assert.notEqual(clusterUrl.rendererClusterUrl, newClusterUrl);
assert.notEqual(mockIPC.clusterUrl, newClusterUrl);
await controller.setClusterUrl(newClusterUrl);
assert.strictEqual(clusterUrl.rendererClusterUrl, newClusterUrl);
assert.strictEqual(mockIPC.clusterUrl, newClusterUrl);
});
});