Files
threshold-ui/ui/admin/tests/unit/abilities/collection-test.js
T

27 lines
1.0 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
*/
2021-08-19 17:52:27 -04:00
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | model', function (hooks) {
2021-08-19 17:52:27 -04:00
setupTest(hooks);
test('it reflects when a resource may be navigated to based on list and create actions', function (assert) {
2026-02-24 13:48:34 -05:00
const service = this.owner.lookup('service:abilities');
2021-08-19 17:52:27 -04:00
const model = {
authorized_collection_actions: { foobars: [] },
};
assert.notOk(
service.can('navigate model', model, { collection: 'foobars' }),
2021-08-19 17:52:27 -04:00
);
model.authorized_collection_actions.foobars = ['list'];
assert.ok(service.can('navigate model', model, { collection: 'foobars' }));
2021-08-19 17:52:27 -04:00
model.authorized_collection_actions.foobars = ['create'];
assert.ok(service.can('navigate model', model, { collection: 'foobars' }));
2021-08-19 17:52:27 -04:00
model.authorized_collection_actions.foobars = ['list', 'create'];
assert.ok(service.can('navigate model', model, { collection: 'foobars' }));
2021-08-19 17:52:27 -04:00
});
});