Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return if Vue.$isServer', () => {
isServer(true);
expect(wrapper.vm.createPopper()).toEqual(undefined);
isServer(false);
});
it('should not add window resize event listener if Vue.$isServer', () => {
isServer(true, wrapper.vm);
const spy = jest.spyOn(window, 'addEventListener');
wrapper.vm.created();
expect(spy).not.toHaveBeenCalledTimes(3);
isServer(false, wrapper.vm);
});
});
it('should return if Vue.$isServer', () => {
isServer(true);
expect(triggerEvent(element, 'eventName')).not.toBeDefined();
isServer(false);
});
it('should equal 0 if window is not defined', () => {
isServer(true);
expect(createWrapper().vm.windowWidth).toEqual(0);
isServer(false);
});
});
it('should be a function calling detachEventBinding on element', () => {
isServer(true);
const spy = jest.spyOn(element, 'detachEvent');
const fn = () => {};
_off()(element, 'eventName', fn);
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('oneventName', fn);
isServer(false);
});
it('should not bind mousedown and mouseup events if Vue.$isServer', () => {
isServer(true);
const spy = jest.spyOn(window.document, 'addEventListener');
bindClickOutsideHandler();
expect(spy).not.toHaveBeenCalledTimes(5);
isServer(false);
});
});
it('should not remove window resize event listener if $isServer', () => {
isServer(true, wrapper.vm);
const spy = jest.spyOn(window, 'removeEventListener');
wrapper.vm.beforeDestroy();
expect(spy).not.toHaveBeenCalled();
isServer(false, wrapper.vm);
});
it('should not remove window resize event listener if Vue.$isServer', () => {
isServer(true, wrapper.vm);
const spy = jest.spyOn(window, 'removeEventListener');
wrapper.vm.destroyed();
expect(spy).not.toHaveBeenCalledTimes(3);
isServer(false, wrapper.vm);
});
});
it('should not call attachEvent binding if event not specified', () => {
isServer(true);
const spy = jest.spyOn(element, 'addEventListener');
const fn = () => {};
_on()(element, undefined, fn);
expect(spy).not.toHaveBeenCalled();
isServer(false);
});
it('should return false if SSR', () => {
isServer(true);
expect(isMobile()).toEqual(false);
isServer(false);
});