Files
threshold-ui/ui/desktop/tests/unit/controllers/cluster-url-test.js
T
Lisbet Alvarez 3ba93927fe Update copyright headers (#3146)
* empty commit

* Add missing copyright headers

* chore: 🤖 update copywrite config file with correct year

* Add missing copyright headers

* empty commit (gh action merge checks are stuck)
2026-01-28 17:09:06 -08:00

47 lines
1.4 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* 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);
});
});