Files
threshold-ui/ui/admin/tests/unit/utils/param-value-finder-test.js
T
hashicorp-copywrite[bot] f102e7fca2 [COMPLIANCE] Add Copyright and License Headers (#1986)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-11-06 09:28:39 -08:00

42 lines
1.1 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
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']);
});
});