Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const spies = Object.keys(lifecycleCallbacks).reduce((acc, key) => {
/* eslint-disable no-param-reassign */
acc[key] = expect.spyOn(lifecycleCallbacks, key);
/* eslint-enable no-param-reassign */
return acc;
}, {});
it(`should call setZoom when props.zoom changes`, () => {
const setZoomSpy = expect.spyOn(maps.Map.prototype, `setZoom`);
expect(setZoomSpy).toNotHaveBeenCalled();
render((
), domEl);
expect(setZoomSpy).toNotHaveBeenCalled();
render((
), domEl);
expect(setZoomSpy).toHaveBeenCalled();
setZoomSpy.restore();
});
});
it(`should call constructor during initial render`, () => {
const constructorSpy = expect.spyOn(maps, `Map`);
expect(constructorSpy).toNotHaveBeenCalled();
render((
), domEl);
expect(constructorSpy).toHaveBeenCalled();
constructorSpy.restore();
});
it(`should warn and throw error`, () => {
const warningSpy = expect.spyOn(console, `error`);
expect(warningSpy).toNotHaveBeenCalled();
let error;
try {
render((
), document.createElement(`div`));
} catch (__e__) {
error = __e__;
}
expect(error).toExist();
expect(warningSpy).toHaveBeenCalled();
warningSpy.restore();
});
});
it(`should call google.maps.event.trigger`, (done) => {
const triggerSpy = expect.spyOn(maps.event, `trigger`);
expect(triggerSpy).toNotHaveBeenCalled();
function ref(component) {
triggerEvent(component, `resize`);
expect(triggerSpy).toHaveBeenCalled();
triggerSpy.restore();
done();
}
render((
}
googleMapElement={}
/>
), document.createElement(`div`));