@kiwicom/smart-faq
Version:
38 lines (31 loc) • 1.18 kB
JavaScript
// @flow
import * as chatUtils from '../utils';
import chatConfig from '../__fixtures__/ChatConfig';
describe('GuaranteeChat/utils', () => {
/* eslint-disable accessor-pairs */
// $FlowExpectedError: Expected
Object.defineProperty(HTMLScriptElement.prototype, 'src', {
// Define the property setter
set() {
setTimeout(() => this.onload());
},
});
it('should initialize webchat', async () => {
// $FlowExpectedError: Expected
document.body.innerHTML = '<div id="testId" />';
await chatUtils.initialize(chatConfig, 'testId');
// $FlowExpectedError: Expected
expect(document.body.querySelector('script')).toBeTruthy();
});
it('should initialize with only one script tag', () => {
// $FlowExpectedError: Expected
document.body.innerHTML =
'<div id="testId"><script id="purecloud-webchat-js" /></div>';
// $FlowExpectedError: Expected
const script = document.body.querySelector('script');
// $FlowExpectedError: Expected
expect(document.body.querySelectorAll('script')).toHaveLength(1);
// $FlowExpectedError: Expected
expect(document.body.querySelector('script')).toBe(script);
});
});