vault/ui/tests/unit/utils/api-path-test.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

29 lines
879 B
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import apiPath from 'vault/utils/api-path';
import { module, test } from 'qunit';
module('Unit | Util | api path', function () {
test('it returns a function', function (assert) {
const ret = apiPath`foo`;
assert.strictEqual(typeof ret, 'function');
});
test('it iterpolates strings from passed context object', function (assert) {
const ret = apiPath`foo/${'one'}/${'two'}`;
const result = ret({ one: 1, two: 2 });
assert.strictEqual(result, 'foo/1/2', 'returns the expected string');
});
test('it throws when the key is not found in the context', function (assert) {
const ret = apiPath`foo/${'one'}/${'two'}`;
assert.throws(() => {
ret({ one: 1 });
}, /Error: Assertion Failed: Expected 2 keys in apiPath context, only recieved one/);
});
});