"use strict";
/**
 * @jest-environment node
 */
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("./config");
const types_1 = require("./types");
const embedConfig = {
    authType: types_1.AuthType.SSO,
};
describe('getThoughtSpotHost', () => {
    test('invalid config', () => {
        const testFn = () => {
            (0, config_1.getThoughtSpotHost)({
                ...embedConfig,
                thoughtSpotHost: null,
            });
        };
        expect(testFn).toThrow(Error);
    });
    test('IP address/hostname only', () => {
        expect((0, config_1.getThoughtSpotHost)({
            ...embedConfig,
            thoughtSpotHost: '1.2.3.4',
        })).toBe('https://1.2.3.4');
        expect((0, config_1.getThoughtSpotHost)({
            ...embedConfig,
            thoughtSpotHost: 'myhost',
        })).toBe('https://myhost');
    });
    test('host name and protocol', () => {
        expect((0, config_1.getThoughtSpotHost)({
            ...embedConfig,
            thoughtSpotHost: 'http://myhost',
        })).toBe('http://myhost');
    });
    test('host name, protocol and port', () => {
        expect((0, config_1.getThoughtSpotHost)({
            ...embedConfig,
            thoughtSpotHost: 'http://myhost:8088/',
        })).toBe('http://myhost:8088');
    });
    test('fully formed URL', () => {
        expect((0, config_1.getThoughtSpotHost)({
            ...embedConfig,
            thoughtSpotHost: 'http://1.2.3.4:8088/v2/?foo=bar&baz=42#myhash',
        })).toBe('http://1.2.3.4:8088/v2');
    });
    test('when authtype SAML, fully formed URL with', () => {
        expect((0, config_1.getThoughtSpotHost)({
            ...embedConfig,
            authType: types_1.AuthType.SAML,
            thoughtSpotHost: 'http://1.2.3.4:8088/v2/?foo=bar&baz=42#myhash',
        })).toBe('http://1.2.3.4:8088/v2');
    });
    test('Return correct v2 basepath', () => {
        const basePath = (0, config_1.getV2BasePath)({
            basepath: 'test',
            thoughtSpotHost: '',
            authType: types_1.AuthType.None,
        });
        expect(basePath).toBe('test');
    });
});
//# sourceMappingURL=config.spec.js.map