jest-webextension-mock
Advanced tools
Comparing version 3.8.1 to 3.8.2
@@ -21,2 +21,3 @@ 'use strict'; | ||
var onMessageListeners = []; | ||
var onMessageExternalListeners = []; | ||
var runtime = { | ||
@@ -63,2 +64,15 @@ connect: jest.fn(function (_ref) { | ||
}, | ||
onMessageExternal: { | ||
addListener: jest.fn(function (listener) { | ||
onMessageExternalListeners.push(listener); | ||
}), | ||
removeListener: jest.fn(function (listener) { | ||
onMessageExternalListeners = onMessageExternalListeners.filter(function (lstn) { | ||
return lstn !== listener; | ||
}); | ||
}), | ||
hasListener: jest.fn(function (listener) { | ||
return onMessageExternalListeners.includes(listener); | ||
}) | ||
}, | ||
onConnect: { | ||
@@ -77,3 +91,8 @@ addListener: jest.fn(), | ||
}), | ||
openOptionsPage: jest.fn() | ||
openOptionsPage: jest.fn(), | ||
getManifest: jest.fn(function () { | ||
return { | ||
manifest_version: 3 | ||
}; | ||
}) | ||
}; | ||
@@ -84,3 +103,3 @@ | ||
get: jest.fn(function () { | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { }; | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; | ||
return cb({}); | ||
@@ -126,3 +145,3 @@ }), | ||
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { }; | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; | ||
return cb(Object.assign({}, { | ||
@@ -133,7 +152,7 @@ id: id | ||
query: jest.fn(function () { | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { }; | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; | ||
return cb([{}]); | ||
}), | ||
highlight: jest.fn(function () { | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { }; | ||
var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; | ||
return cb(); | ||
@@ -144,3 +163,3 @@ }), | ||
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () { }; | ||
var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; | ||
return cb(Object.assign({}, props, { | ||
@@ -153,3 +172,3 @@ id: id | ||
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () { }; | ||
var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; | ||
return cb(ids.map(function (id) { | ||
@@ -492,16 +511,42 @@ return Object.assign({}, props, { | ||
var cbOrPromise$1 = function cbOrPromise(cb, value) { | ||
if (cb !== undefined) { | ||
return cb(value); | ||
} | ||
return Promise.resolve(value); | ||
}; | ||
var downloads = { | ||
acceptDanger: jest.fn((downloadId, cb) => cbOrPromise(cb)), | ||
cancel: jest.fn((downloadId, cb) => cbOrPromise(cb)), | ||
download: jest.fn((options, cb) => cbOrPromise(cb)), | ||
erase: jest.fn((query, cb) => cbOrPromise(cb)), | ||
getFileIcon: jest.fn((downloadId, cb) => cbOrPromise(cb)), | ||
acceptDanger: jest.fn(function (downloadId, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
cancel: jest.fn(function (downloadId, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
download: jest.fn(function (options, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
erase: jest.fn(function (query, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
getFileIcon: jest.fn(function (downloadId, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
open: jest.fn(), | ||
pause: jest.fn((downloadId, cb) => cbOrPromise(cb)), | ||
removeFile: jest.fn((downloadId, cb) => cbOrPromise(cb)), | ||
resume: jest.fn((downloadId, cb) => cbOrPromise(cb)), | ||
search: jest.fn((query, cb) => cbOrPromise(cb)), | ||
pause: jest.fn(function (downloadId, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
removeFile: jest.fn(function (downloadId, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
resume: jest.fn(function (downloadId, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
search: jest.fn(function (query, cb) { | ||
return cbOrPromise$1(cb); | ||
}), | ||
setShelfEnabled: jest.fn(), | ||
show: jest.fn(), | ||
showDefaultFolder: jest.fn(), | ||
showDefaultFolder: jest.fn() | ||
}; | ||
@@ -548,5 +593,5 @@ | ||
extension: extension, | ||
downloads: downloads, | ||
downloads: downloads | ||
}; | ||
// Firefox uses 'browser' but aliases it to chrome | ||
// Firefox uses 'browser' but aliases it to chrome | ||
@@ -553,0 +598,0 @@ /** |
{ | ||
"name": "jest-webextension-mock", | ||
"version": "3.8.1", | ||
"version": "3.8.2", | ||
"description": "Mock the components of a WebExtension", | ||
@@ -47,3 +47,4 @@ "main": "dist/setup.js", | ||
] | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74109
1964