jest-webextension-mock
Advanced tools
Comparing version 1.0.0 to 2.0.0
{ | ||
"name": "jest-webextension-mock", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Mock the components of a WebExtension", | ||
"main": "src/index.js", | ||
"main": "dist/setup.js", | ||
"module": "src/setup.js", | ||
"author": "Bryan Clark <clarkbw@gmail.com> (https://twitter.com/clarkbw)", | ||
@@ -10,3 +11,4 @@ "license": "ISC", | ||
"test": "jest", | ||
"prettier": "prettier --single-quote --trailing-comma es5 --write \"{src,__{tests,setups}__}/**/*.js\"", | ||
"build": "rollup -c", | ||
"prettier": "prettier --single-quote --trailing-comma es5 --write \"{config,src,__{tests,setups}__}/**/*.js\" rollup.config.js", | ||
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check" | ||
@@ -16,3 +18,5 @@ }, | ||
"babel-jest": "^19.0.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-env": "^1.4.0", | ||
"babel-preset-latest": "^6.24.1", | ||
"eslint": "^3.19.0", | ||
@@ -22,3 +26,6 @@ "eslint-config-prettier": "^1.7.0", | ||
"jest": "^19.0.2", | ||
"prettier": "^1.3.1" | ||
"prettier": "^1.3.1", | ||
"rollup": "^0.41.6", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-node-resolve": "^3.0.0" | ||
}, | ||
@@ -25,0 +32,0 @@ "jest": { |
@@ -1,4 +0,1 @@ | ||
// Chrome globals are setup in the "jest" property of the package.json | ||
// This setup file sets the chrome global with mock functions | ||
import { omnibox } from './omnibox'; | ||
@@ -5,0 +2,0 @@ import { tabs } from './tabs'; |
// https://developer.chrome.com/extensions/tabs | ||
const RT_TAB = () => TAB; | ||
export const tabs = { | ||
get: jest.fn((id, cb) => cb(TAB)), | ||
get: jest.fn((id = '', cb = RT_TAB) => cb(TAB)), | ||
getCurrent: jest.fn(cb => cb(TAB)), | ||
connect: jest.fn(), // id, obj | ||
create: jest.fn((props, cb) => cb(Object.assign(props, TAB))), | ||
duplicate: jest.fn((id, cb) => cb(Object.assign(TAB, { id }))), | ||
query: jest.fn((query, cb) => cb([TAB])), | ||
highlight: jest.fn((info, cb) => cb()), | ||
update: jest.fn((id, props, cb) => cb(TAB)), | ||
move: jest.fn((ids, props, cb) => cb([TAB])), | ||
create: jest.fn((props = {}, cb = RT_TAB) => cb(Object.assign(props, TAB))), | ||
duplicate: jest.fn((id = '', cb = RT_TAB) => cb(Object.assign(TAB, { id }))), | ||
query: jest.fn((query = '', cb = RT_TAB) => cb([TAB])), | ||
highlight: jest.fn((info = {}, cb = RT_TAB) => cb()), | ||
update: jest.fn((id = '', props = {}, cb = RT_TAB) => cb(TAB)), | ||
move: jest.fn((ids = [], props = {}, cb = RT_TAB) => cb([TAB])), | ||
}; | ||
let TAB = { | ||
index: 1, | ||
windowId: 1, | ||
highlighted: false, | ||
active: false, | ||
pinned: false, | ||
discarded: false, | ||
autoDiscardable: false, | ||
incognito: false, | ||
}; | ||
/* | ||
index: 1, | ||
windowId: 1, | ||
highlighted: false, | ||
active: false, | ||
pinned: false, | ||
discarded: false, | ||
autoDiscardable: false, | ||
incognito: false, | ||
*/ | ||
let TAB = {}; | ||
@@ -26,0 +29,0 @@ export function mock(tab) { |
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
10281
15
208
12