github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/unit/utils/add-to-path-test.js (about) 1 import { module, test } from 'qunit'; 2 import addToPath from 'nomad-ui/utils/add-to-path'; 3 4 const testCases = [ 5 { 6 name: 'Only domain', 7 in: ['https://domain.com', '/path'], 8 out: 'https://domain.com/path', 9 }, 10 { 11 name: 'Deep path', 12 in: ['https://domain.com/a/path', '/to/nowhere'], 13 out: 'https://domain.com/a/path/to/nowhere', 14 }, 15 { 16 name: 'With Query Params', 17 in: ['https://domain.com?interesting=development', '/this-is-an'], 18 out: 'https://domain.com/this-is-an?interesting=development', 19 }, 20 ]; 21 22 module('Unit | Util | addToPath', function () { 23 testCases.forEach((testCase) => { 24 test(testCase.name, function (assert) { 25 assert.equal( 26 addToPath.apply(null, testCase.in), 27 testCase.out, 28 `[${testCase.in.join(', ')}] => ${testCase.out}` 29 ); 30 }); 31 }); 32 });