Skip to content

Commit bde3400

Browse files
authored
Merge pull request #53 from aeksco/bug/fix-broken-broser-polyfill
Fix webextension-polyfill mock
2 parents 1620e37 + 21b7c36 commit bde3400

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/__mocks__/webextension-polyfill.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This is used to mock these values for Storybook so you can develop your components
44
// outside the Web Extension environment provided by a compatible browser
55
// See .storybook/main.js to see how this module is swapped in for `webextension-polyfill`
6-
export const browser: any = {
6+
const browser: any = {
77
tabs: {
88
executeScript(currentTabId: number, details: any) {
99
return Promise.resolve({ done: true });
@@ -18,6 +18,7 @@ export const browser: any = {
1818
},
1919
},
2020
};
21+
export default browser;
2122

2223
interface Tab {
2324
id: number;

src/popup/component.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function scrollWindow(position: number) {
2020
*/
2121
function executeScript(position: number): void {
2222
// Query for the active tab in the current window
23-
browser?.tabs
23+
browser.tabs
2424
.query({ active: true, currentWindow: true })
2525
.then((tabs: Tabs.Tab[]) => {
2626
// Pulls current tab from browser.tabs.query response
@@ -52,9 +52,7 @@ function executeScript(position: number): void {
5252
export function Popup() {
5353
// Sends the `popupMounted` event
5454
React.useEffect(() => {
55-
// NOTE - we use conditional chaining on `browser`import
56-
// because it doesn't load up in Storybook
57-
browser?.runtime.sendMessage({ popupMounted: true });
55+
browser.runtime.sendMessage({ popupMounted: true });
5856
}, []);
5957

6058
// Renders the component tree

0 commit comments

Comments
 (0)