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

27 lines
1017 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2021-08-19 17:52:27 -04:00
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
2022-01-31 12:02:37 -05:00
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) {
const service = this.owner.lookup('service:can');
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'];
2022-01-31 12:02:37 -05:00
assert.ok(service.can('navigate model', model, { collection: 'foobars' }));
2021-08-19 17:52:27 -04:00
model.authorized_collection_actions.foobars = ['create'];
2022-01-31 12:02:37 -05:00
assert.ok(service.can('navigate model', model, { collection: 'foobars' }));
2021-08-19 17:52:27 -04:00
model.authorized_collection_actions.foobars = ['list', 'create'];
2022-01-31 12:02:37 -05:00
assert.ok(service.can('navigate model', model, { collection: 'foobars' }));
2021-08-19 17:52:27 -04:00
});
});