open-nomad/ui/tests/unit/utils/add-to-path-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
914 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2019-05-15 22:33:58 +00:00
import { module, test } from 'qunit';
import addToPath from 'nomad-ui/utils/add-to-path';
const testCases = [
{
name: 'Only domain',
in: ['https://domain.com', '/path'],
out: 'https://domain.com/path',
},
{
name: 'Deep path',
in: ['https://domain.com/a/path', '/to/nowhere'],
out: 'https://domain.com/a/path/to/nowhere',
},
{
name: 'With Query Params',
in: ['https://domain.com?interesting=development', '/this-is-an'],
out: 'https://domain.com/this-is-an?interesting=development',
},
];
2021-12-28 14:45:20 +00:00
module('Unit | Util | addToPath', function () {
testCases.forEach((testCase) => {
test(testCase.name, function (assert) {
2019-05-15 22:33:58 +00:00
assert.equal(
addToPath.apply(null, testCase.in),
testCase.out,
`[${testCase.in.join(', ')}] => ${testCase.out}`
);
});
});
});