Files
threshold-ui/addons/api/tests/unit/abilities/scope-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

41 lines
1.2 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | Scope', function (hooks) {
setupTest(hooks);
let canService;
hooks.beforeEach(function () {
canService = this.owner.lookup('service:can');
});
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'],
};
assert.true(canService.can('attachStoragePolicy scope', model));
model.authorized_actions = [];
assert.false(canService.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'],
};
assert.true(canService.can('detachStoragePolicy scope', model));
model.authorized_actions = [];
assert.false(canService.can('detachStoragePolicy scope', model));
});
});