about summary refs log tree commit diff
path: root/spec/javascript/setup.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascript/setup.js')
-rw-r--r--spec/javascript/setup.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/javascript/setup.js b/spec/javascript/setup.js
new file mode 100644
index 000000000..636cdcc7e
--- /dev/null
+++ b/spec/javascript/setup.js
@@ -0,0 +1,22 @@
+/**
+ * http://airbnb.io/enzyme/docs/guides/jsdom.html
+ */
+var jsdom = require('jsdom').jsdom;
+
+var exposedProperties = ['window', 'navigator', 'document'];
+
+global.document = jsdom('');
+global.window = document.defaultView;
+Object.keys(document.defaultView).forEach((property) => {
+  if (typeof global[property] === 'undefined') {
+    exposedProperties.push(property);
+    global[property] = document.defaultView[property];
+  }
+});
+
+global.navigator = {
+  userAgent: 'node.js'
+};
+
+var React    = window.React    = global.React    = require('react');
+var ReactDOM = window.ReactDOM = global.ReactDOM = require('react-dom');