Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions WebContent/js/utilities/urlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export function encodeURLComponent(URL: string) {
}

export function whichServer() {
let server = location.host;
if (location.hostname === 'tester.test.com') {
server = 'tester.test.com:7443';
}
const server = location.host;
return server;
}

Expand Down
18 changes: 13 additions & 5 deletions tests/UnitTests/testDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@
*/

import {
LOCAL_HOST_SERVER_WITH_PROTOCOL as LOCAL_SERVER,
LOCAL_HOSTNAME,
LOCAL_HOST_SERVER,
LOCAL_HOST_SERVER_WITH_PROTOCOL
} from './testResources/hostConstants';

(global as any).location = {
hostname: LOCAL_HOSTNAME,
origin: `${LOCAL_SERVER}`,
};
Object.defineProperty(globalThis, 'location', {
value: {
host: LOCAL_HOST_SERVER,
hostname: LOCAL_HOSTNAME,
protocol: 'https:',
href: LOCAL_HOST_SERVER_WITH_PROTOCOL,
origin: LOCAL_HOST_SERVER_WITH_PROTOCOL
},
writable: true,
configurable: true
});
13 changes: 13 additions & 0 deletions tests/UnitTests/testResources/hostConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ export const LOCAL_HOSTNAME = 'tester.test.com';
export const LOCAL_HOST_SERVER = `${LOCAL_HOSTNAME}:7443`;
export const LOCAL_HOST_SERVER_WITH_PROTOCOL = `https://${LOCAL_HOST_SERVER}`;
export const LOCAL_HOST_ENDPOINT = `${LOCAL_HOST_SERVER_WITH_PROTOCOL}/ibmzosmf/api/v1`;

// Stubbing object for tests
Object.defineProperty(globalThis, 'location', {
value: {
host: LOCAL_HOST_SERVER,
hostname: LOCAL_HOSTNAME,
protocol: 'https:',
href: LOCAL_HOST_SERVER_WITH_PROTOCOL,
origin: LOCAL_HOST_SERVER_WITH_PROTOCOL
},
writable: true, // Allows individual tests to change it if needed
configurable: true
});
Loading