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

33 lines
832 B
JavaScript
Raw Normal View History

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',
},
];
module('Unit | Util | addToPath', function() {
testCases.forEach(testCase => {
test(testCase.name, function(assert) {
assert.equal(
addToPath.apply(null, testCase.in),
testCase.out,
`[${testCase.in.join(', ')}] => ${testCase.out}`
);
});
});
});