diff --git a/tests/unit/network/rest/utils.js b/tests/unit/network/rest/utils.js new file mode 100644 index 000000000..c151a5887 --- /dev/null +++ b/tests/unit/network/rest/utils.js @@ -0,0 +1,26 @@ +'use strict'; // eslint-disable-line + +const assert = require('assert'); +const constants = require('../../../../lib/constants'); +const { parseURL } = require('../../../../lib/network/rest/utils'); + +describe('parseURL function', () => { + [ + { + inputUrl: `${constants.passthroughFileURL}/test`, + expectedKey: 'test', + }, + { + inputUrl: `${constants.passthroughFileURL}/test with spaces`, + expectedKey: 'test with spaces', + }, + ].forEach(testCase => { + const { inputUrl, expectedKey } = testCase; + + it(`should return ${expectedKey} with url "${inputUrl}"`, + () => { + const pathInfo = parseURL(inputUrl, true); + assert.strictEqual(pathInfo.key, expectedKey); + }); + }); +});