@thoughtspot/visual-embed-sdk
Version:
ThoughtSpot Embed SDK
29 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const authToken_1 = require("./authToken");
const authServiceInstance = tslib_1.__importStar(require("./utils/authService/authService"));
describe('AuthToken Unit tests', () => {
test('getAuthenticationToken: When verification is disabled', async () => {
jest.spyOn(authServiceInstance, 'verifyTokenService');
const token = await (0, authToken_1.getAuthenticationToken)({
getAuthToken: async () => 'abc3',
disableTokenVerification: true,
});
expect(token).toBe('abc3');
expect(authServiceInstance.verifyTokenService).not.toBeCalled();
});
test('getAuthenticationToken: When verification is enabled', async () => {
(0, authToken_1.resetCachedAuthToken)();
jest.clearAllMocks();
jest.spyOn(authServiceInstance, 'verifyTokenService').mockImplementation(() => true);
const token = await (0, authToken_1.getAuthenticationToken)({
thoughtSpotHost: 'test',
getAuthToken: async () => 'abc2',
disableTokenVerification: false,
});
expect(token).toBe('abc2');
expect(authServiceInstance.verifyTokenService).toBeCalledWith('test', 'abc2');
});
});
//# sourceMappingURL=authToken.spec.js.map