57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
import { jest } from '@jest/globals';
|
|
|
|
chrome.action = {
|
|
...chrome.action,
|
|
openPopup: jest.fn(),
|
|
setBadgeBackgroundColor: jest.fn(),
|
|
setBadgeText: jest.fn(),
|
|
setIcon: jest.fn(),
|
|
} as typeof chrome.action;
|
|
|
|
chrome.contextMenus = {
|
|
...chrome.contextMenus,
|
|
create: jest.fn(),
|
|
onClicked: {
|
|
...(chrome.contextMenus ?? {}).onClicked,
|
|
addListener: jest.fn(),
|
|
},
|
|
removeAll: jest.fn(),
|
|
} as typeof chrome.contextMenus;
|
|
|
|
chrome.declarativeNetRequest = {
|
|
...chrome.declarativeNetRequest,
|
|
updateSessionRules: jest.fn(),
|
|
} as typeof chrome.declarativeNetRequest;
|
|
|
|
chrome.runtime = {
|
|
...chrome.runtime,
|
|
getManifest: jest.fn(
|
|
() =>
|
|
({
|
|
content_scripts: [{ matches: ['https://example.com/*'] }],
|
|
version: '1.0.0',
|
|
}) as chrome.runtime.ManifestV3
|
|
),
|
|
onInstalled: {
|
|
...(chrome.runtime ?? {}).onInstalled,
|
|
addListener: jest.fn(),
|
|
},
|
|
onStartup: {
|
|
...(chrome.runtime ?? {}).onStartup,
|
|
addListener: jest.fn(),
|
|
},
|
|
openOptionsPage: jest.fn(),
|
|
} as typeof chrome.runtime;
|
|
|
|
chrome.webRequest = {
|
|
...chrome.webRequest,
|
|
onBeforeRequest: {
|
|
...(chrome.webRequest ?? {}).onBeforeRequest,
|
|
addListener: jest.fn(),
|
|
},
|
|
onErrorOccurred: {
|
|
...(chrome.webRequest ?? {}).onErrorOccurred,
|
|
addListener: jest.fn(),
|
|
},
|
|
} as typeof chrome.webRequest;
|