github.com/hernad/nomad@v1.6.112/ui/tests/unit/utils/add-to-path-test.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { module, test } from 'qunit';
     7  import addToPath from 'nomad-ui/utils/add-to-path';
     8  
     9  const testCases = [
    10    {
    11      name: 'Only domain',
    12      in: ['https://domain.com', '/path'],
    13      out: 'https://domain.com/path',
    14    },
    15    {
    16      name: 'Deep path',
    17      in: ['https://domain.com/a/path', '/to/nowhere'],
    18      out: 'https://domain.com/a/path/to/nowhere',
    19    },
    20    {
    21      name: 'With Query Params',
    22      in: ['https://domain.com?interesting=development', '/this-is-an'],
    23      out: 'https://domain.com/this-is-an?interesting=development',
    24    },
    25  ];
    26  
    27  module('Unit | Util | addToPath', function () {
    28    testCases.forEach((testCase) => {
    29      test(testCase.name, function (assert) {
    30        assert.equal(
    31          addToPath.apply(null, testCase.in),
    32          testCase.out,
    33          `[${testCase.in.join(', ')}] => ${testCase.out}`
    34        );
    35      });
    36    });
    37  });