2021-01-07 20:18:36 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Unit | Service | feature-flag', function (hooks) {
|
2021-01-07 20:18:36 +00:00
|
|
|
setupTest(hooks);
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it exists', function (assert) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const service = this.owner.lookup('service:feature-flag');
|
2021-01-07 20:18:36 +00:00
|
|
|
assert.ok(service);
|
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it returns the namespace root when flag is present', function (assert) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const service = this.owner.lookup('service:feature-flag');
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(service.managedNamespaceRoot, null, 'Managed namespace root is null by default');
|
2021-01-07 20:18:36 +00:00
|
|
|
service.setFeatureFlags(['VAULT_CLOUD_ADMIN_NAMESPACE']);
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(service.managedNamespaceRoot, 'admin', 'Managed namespace is admin when flag present');
|
2021-01-07 20:18:36 +00:00
|
|
|
service.setFeatureFlags(['SOMETHING_ELSE']);
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(
|
2021-01-07 20:18:36 +00:00
|
|
|
service.managedNamespaceRoot,
|
|
|
|
null,
|
|
|
|
'Flags were overwritten and root namespace is null again'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|