Files
threshold-ui/addons/api/tests/unit/abilities/worker-test.js
T
hashicc b5d33948dc chore: 🤖 bump ember-can (#3093)
* chore: 🤖 bump ember-can

* chore: 🤖 rename "can" service (deprecated) to abilities

See https://github.com/minutebase/ember-can/pull/152

* chore: 🤖 bump to ember-can@^8

* chore: 🤖 extend resolver for ember-can v7 breaking change

https://github.com/minutebase/ember-can/pull/186
2025-12-08 10:41:38 -05:00

59 lines
1.5 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | Worker', function (hooks) {
setupTest(hooks);
let abilitiesService;
let store;
const instances = {
worker: null,
};
hooks.beforeEach(function () {
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(
abilitiesService.can('createWorkerLed worker', model, {
collection: 'workers',
}),
);
});
test('cannot create worker-led', function (assert) {
const model = {
authorized_collection_actions: { workers: [] },
};
assert.true(
abilitiesService.cannot('createWorkerLed worker', model, {
collection: 'workers',
}),
);
});
test('can set worker tags', function (assert) {
instances.worker.authorized_actions = ['set-worker-tags'];
assert.true(abilitiesService.can('setWorkerTags worker', instances.worker));
});
test('cannot set worker tags', function (assert) {
instances.worker.authorized_actions = [];
assert.true(
abilitiesService.cannot('setWorkerTags worker', instances.worker),
);
});
});