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

28 lines
1.0 KiB
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) {
assert.expect(4);
const service = this.owner.lookup('service:can');
const model = {
authorized_collection_actions: { foobars: [] },
};
assert.notOk(
2022-01-31 12:02:37 -05:00
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
});
});