Files
threshold-ui/addons/api/tests/unit/abilities/scope-test.js
T

40 lines
1.2 KiB
JavaScript
Raw Normal View History

/**
2026-01-28 17:09:06 -08:00
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | Scope', function (hooks) {
setupTest(hooks);
2026-02-24 13:48:34 -05:00
let abilitiesService;
hooks.beforeEach(function () {
2026-02-24 13:48:34 -05:00
abilitiesService = this.owner.lookup('service:abilities');
});
test('it exists', function (assert) {
const ability = this.owner.lookup('ability:scope');
assert.ok(ability);
});
test('it reflects when a given scope may attach a policy in global scope', function (assert) {
const model = {
authorized_actions: ['attach-storage-policy'],
};
2026-02-24 13:48:34 -05:00
assert.true(abilitiesService.can('attachStoragePolicy scope', model));
model.authorized_actions = [];
2026-02-24 13:48:34 -05:00
assert.false(abilitiesService.can('attachStoragePolicy scope', model));
});
test('it reflects when a given scope may remove a policy in org scope', function (assert) {
const model = {
authorized_actions: ['detach-storage-policy'],
};
2026-02-24 13:48:34 -05:00
assert.true(abilitiesService.can('detachStoragePolicy scope', model));
model.authorized_actions = [];
2026-02-24 13:48:34 -05:00
assert.false(abilitiesService.can('detachStoragePolicy scope', model));
});
});