Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// global functions to mount vue components
global.mount = mount;
global.shallowMount = shallowMount; // use when you don't want to render child components
// mock logger, so you can check that mockLogger was called
global.mockLogger = jest.fn();
jest.mock('clay-log', () => ({
init: () => {},
meta: () => mockLogger
}));
global.window.kiln = { inputs: {} };
// mock cuid because it doesn't like being run in jsdom
jest.mock('cuid');
cuid.default.mockReturnValue('abc');
// add jsdom-compliant quill polyfill for dealing with deltas
jest.mock('quill/dist/quill.min.js');
Quill.mockImplementation(function QuillMock() {
this.root = { innerHTML: '' };
this.setContents = function (delta) {
this.root.innerHTML = convertDeltaToHtml(delta);
};
this.imports = {}; // phrase blots
this.register = function (blotName, blotConfig) {
this.imports[blotName] = blotConfig;
};
});
// note: yeah, we're using actual quill deltas here. pretty snazzy eh?
Quill.import.mockImplementation(() => Delta);