Files
threshold-ui/ui/admin/tests/unit/utils/param-value-finder-test.js
T
0129784322 fix url when user tries to access resource with incorrect url (#1958)
* refactor: 💡 auth-method, account, & managed abilities & routes

* refactor: 💡 credential store resources abilities & routes

* refactor: 💡 group abilities & routes

* refactor: 💡 host-catalog resources abilities & routes

* refactor: 💡 role abilities & routes

* test: 💍 fix route-info-test

* test: 💍 fix host serializer tests

* test: 💍 fix create-test for host-sets

* refactor: 💡 session recording resources abilities & routes

* refactor: 💡 storage bucket abilities & routes

* refactor: 💡 target abilities & routes

* refactor: 💡 user abilities & routes

* refactor: 💡 worker abilities & routes

* refactor: 💡 remove ability changes and add comments

* Update ui/admin/app/utils/route-info.js

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

* test: 💍 add test cases and rename util file

* refactor: 💡 remove dup file and update imports

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-11282

* docs: ✏️ update comments & remove console.log

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-11282

* Update ui/admin/app/routes/scopes/scope/auth-methods/auth-method.js

Co-authored-by: Dharini Jeeva <dharini@hashicorp.com>

---------

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
Co-authored-by: Dharini Jeeva <dharini@hashicorp.com>
2023-11-02 16:08:25 -07:00

37 lines
1.0 KiB
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { paramValueFinder } from 'admin/utils/param-value-finder';
module('Unit | Utility | param-value-finder', function (hooks) {
setupTest(hooks);
let router;
hooks.beforeEach(function () {
router = this.owner.lookup('service:router');
});
test('returns empty array when null or empty routeInfo object is used', function (assert) {
assert.expect(2);
let result = paramValueFinder('scopes', null);
assert.deepEqual(result, []);
result = paramValueFinder('scopes', {});
assert.deepEqual(result, []);
});
test('returns correct array when routeInfo object is used', function (assert) {
assert.expect(2);
let routeInfo = router.recognize('/scopes');
let result = paramValueFinder('scopes', routeInfo.parent);
assert.deepEqual(result, []);
routeInfo = router.recognize('/scopes/global/auth-methods');
result = paramValueFinder('scopes', routeInfo.parent);
assert.deepEqual(result, ['global']);
});
});