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

58 lines
1.5 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 | Worker', function (hooks) {
setupTest(hooks);
2026-02-24 13:48:34 -05:00
let abilitiesService;
let store;
const instances = {
worker: null,
};
hooks.beforeEach(function () {
2026-02-24 13:48:34 -05:00
abilitiesService = this.owner.lookup('service:abilities');
store = this.owner.lookup('service:store');
instances.worker = store.createRecord('worker');
});
test('can create worker-led', function (assert) {
const model = {
authorized_collection_actions: { workers: ['create:worker-led'] },
};
assert.true(
2026-02-24 13:48:34 -05:00
abilitiesService.can('createWorkerLed worker', model, {
collection: 'workers',
}),
);
});
test('cannot create worker-led', function (assert) {
const model = {
authorized_collection_actions: { workers: [] },
};
assert.true(
2026-02-24 13:48:34 -05:00
abilitiesService.cannot('createWorkerLed worker', model, {
collection: 'workers',
}),
);
});
test('can set worker tags', function (assert) {
instances.worker.authorized_actions = ['set-worker-tags'];
2026-02-24 13:48:34 -05:00
assert.true(abilitiesService.can('setWorkerTags worker', instances.worker));
});
test('cannot set worker tags', function (assert) {
instances.worker.authorized_actions = [];
2026-02-24 13:48:34 -05:00
assert.true(
abilitiesService.cannot('setWorkerTags worker', instances.worker),
);
});
});