Browse Source

Fix code linting errors

pull/46/merge
Luke Childs 8 years ago
parent
commit
78ec5a6c44
  1. 9
      src/index.js
  2. 4
      test/Arguments should be able to be passed in in either order.js
  3. 2
      test/jsdom arg should set jsdom config.js
  4. 2
      test/window properties should be as expected.js

9
src/index.js

@ -18,8 +18,7 @@ const protectedproperties = (() => Object
)();
// Sets up global browser environment
module.exports = function browserEnv() {
const browserEnv = function () {
// Extract options from args
const args = Array.from(arguments);
const properties = args.filter(arg => Array.isArray(arg))[0];
@ -38,8 +37,12 @@ module.exports = function browserEnv() {
.filter(prop => !(properties && properties.indexOf(prop) === -1))
// Copy what's left to the Node.js global scope
.forEach(prop => global[prop] = window[prop]);
.forEach(prop => {
global[prop] = window[prop];
});
// Return reference to original window object
return window;
};
module.exports = browserEnv;

4
test/Arguments should be able to be passed in in either order.js

@ -3,8 +3,8 @@ import browserEnv from '../src';
test(t => {
t.is(typeof navigator, 'undefined');
const returnValue = browserEnv(['navigator'], { userAgent: 'first' });
browserEnv(['navigator'], { userAgent: 'first' });
t.is(navigator.userAgent, 'first');
const secondReturnValue = browserEnv({ userAgent: 'second' }, ['navigator']);
browserEnv({ userAgent: 'second' }, ['navigator']);
t.is(navigator.userAgent, 'second');
});

2
test/jsdom arg should set jsdom config.js

@ -4,6 +4,6 @@ import browserEnv from '../src';
test(t => {
const userAgent = 'Custom user agent';
t.is(typeof navigator, 'undefined');
browserEnv(['navigator'], { userAgent: userAgent });
browserEnv(['navigator'], { userAgent });
t.is(navigator.userAgent, userAgent);
});

2
test/window properties should be as expected.js

@ -1,6 +1,6 @@
import test from 'ava';
import expectedProperties from './fixtures/expectedProperties';
import browserEnv from '../src';
import expectedProperties from './fixtures/expectedProperties';
test(t => {
browserEnv();

Loading…
Cancel
Save