test: 💍 add missing controller unit tests in admin-ui (#2553)

* test: 💍 add missing controller unit tests in admin-ui

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14740
This commit is contained in:
Lisbet Alvarez authored and GitHub committed 2024-11-12 09:27:07 -08:00
1 parent 7c1814118d
commit 57568f9a8c
77 files changed
+946 -81

No files matched your search

@@ -5,12 +5,57 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { authenticateSession } from 'ember-simple-auth/test-support';
module('Unit | Controller | application', function (hooks) {
setupTest(hooks);
let controller;
let featureEdition;
let featuresService;
let session;
hooks.beforeEach(async function () {
authenticateSession({});
controller = this.owner.lookup('controller:application');
featureEdition = this.owner.lookup('service:featureEdition');
featuresService = this.owner.lookup('service:features');
session = this.owner.lookup('service:session');
});
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:application');
assert.ok(controller);
});
test('invalidateSession action de-authenticates a user', async function (assert) {
assert.true(session.isAuthenticated);
await controller.invalidateSession();
assert.false(session.isAuthenticated);
});
test('toggleTheme action sets theme to specified value', function (assert) {
assert.notOk(session.data.theme);
controller.toggleTheme('light');
assert.strictEqual(session.data.theme, 'light');
});
test('toggleEdition action sets edition to specified value', function (assert) {
assert.notOk(featureEdition.edition);
controller.toggleEdition('oss');
assert.strictEqual(featureEdition.edition, 'oss');
});
test('toggleFeature action toggles specified feature', function (assert) {
assert.false(featuresService.isEnabled('ssh-target'));
controller.toggleFeature('ssh-target');
assert.true(featuresService.isEnabled('ssh-target'));
});
});