2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2022-01-12 09:27:00 +00:00
|
|
|
import resolve from 'consul-ui/utils/path/resolve';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
module('Unit | Utility | path/resolve', function () {
|
|
|
|
test('it resolves paths', function (assert) {
|
2023-02-10 21:32:19 +00:00
|
|
|
assert.expect(9);
|
2022-01-12 09:27:00 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '../edit',
|
|
|
|
expected: 'dc/intentions/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '../../edit',
|
|
|
|
expected: 'dc/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: './edit',
|
|
|
|
expected: 'dc/intentions/create/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '././edit',
|
|
|
|
expected: 'dc/intentions/create/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: './deep/edit',
|
|
|
|
expected: 'dc/intentions/create/deep/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '../deep/edit',
|
|
|
|
expected: 'dc/intentions/deep/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '.././edit',
|
|
|
|
expected: 'dc/intentions/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '../deep/./edit',
|
|
|
|
expected: 'dc/intentions/deep/edit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'dc/intentions/create',
|
|
|
|
to: '/deep/edit',
|
|
|
|
expected: '/deep/edit',
|
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
].forEach((item) => {
|
2022-01-12 09:27:00 +00:00
|
|
|
const actual = resolve(item.from, item.to);
|
|
|
|
assert.equal(
|
|
|
|
actual,
|
|
|
|
item.expected,
|
|
|
|
`Expected '${item.from}' < '${item.to}' to equal ${item.expected}`
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|