Skip to content

Commit 093dbe4

Browse files
authored
fix: drop browser global whitelisting from test harnesses (#1383)
1 parent 61c869f commit 093dbe4

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"extends": "eslint-config-airbnb-base",
33
"env": {
4-
"browser": true,
54
"node": true
65
},
76
"rules": {

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@
9797
"utfstring": "^2.0.0"
9898
},
9999
"jest": {
100-
"globals": {
101-
"navigator": true
102-
},
103100
"testEnvironment": "node",
104101
"testMatch": [
105102
"**/test/*.js?(x)",

src/http.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,19 @@ export function serializeHeaders(headers = {}) {
134134
return obj
135135
}
136136

137-
export function isFile(obj, navigatorObj = navigator) {
137+
export function isFile(obj, navigatorObj) {
138+
if (!navigatorObj && typeof navigator !== 'undefined') {
139+
// eslint-disable-next-line no-undef
140+
navigatorObj = navigator
141+
}
138142
if (navigatorObj && navigatorObj.product === 'ReactNative') {
139143
if (obj && typeof obj === 'object' && typeof obj.uri === 'string') {
140144
return true
141145
}
142146
return false
143147
}
144148
if (typeof File !== 'undefined') {
149+
// eslint-disable-next-line no-undef
145150
return obj instanceof File
146151
}
147152
return obj !== null && typeof obj === 'object' && typeof obj.pipe === 'function'

test/http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ describe('http', () => {
436436
const mockReactNativeNavigator = {
437437
product: 'ReactNative'
438438
}
439-
const browserFile = new File()
439+
440+
const browserFile = new global.File()
440441
const reactNativeFileObject = {
441442
uri: '/mock/path'
442443
}

0 commit comments

Comments
 (0)