import { jsdom } from 'jsdom';

global.document = jsdom('<div id="app"></div>');
global.window = document.defaultView;

Object.keys(document.defaultView).forEach((property) => {
  if (typeof global[property] === 'undefined') {
    global[property] = document.defaultView[property];
  }
});

global.navigator = {
  appName: 'other',
  userAgent: 'node.js',
  platform: 'node.js',
};


const { JSDOM } = require('jsdom');
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');
const { window } = jsdom;

function copyProps(src, target) {
  const props = Object.getOwnPropertyNames(src)
    .filter(prop => typeof target[prop] === 'undefined')
    .map(prop => Object.getOwnPropertyDescriptor(src, prop));
  Object.defineProperties(target, props);
}

global.window = window;
global.document = window.document;
copyProps(window, global);

global.navigator = {
  appName: 'other',
  userAgent: 'node.js',
  platform: 'node.js',
};

Fix jsdom tests to support jsdom10