Skip to content

Commit ecec9ce

Browse files
committed
Remove unused error handling and fix test
1 parent 2b4efc4 commit ecec9ce

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/components/Location.test.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@ import { mount } from '@vue/test-utils';
22
import { NCollapseItem } from 'naive-ui';
33

44
import Location from '@/components/Location.vue';
5-
import useListProxies from '@/composables/useListProxies';
5+
6+
jest.mock('@/composables/useActiveTab', () => ({
7+
__esModule: true,
8+
default: jest.fn(() => ({
9+
activeTabHost: 'example.com',
10+
})),
11+
}));
612

713
jest.mock('@/composables/useListProxies', () => ({
814
__esModule: true,
9-
default: jest.fn(),
15+
default: jest.fn(() => ({
16+
proxiesList: [
17+
{
18+
country: 'Albania',
19+
},
20+
{
21+
country: 'Australia',
22+
},
23+
],
24+
})),
1025
}));
1126

1227
describe('Location', () => {
1328
it('should show two countries', async () => {
14-
(useListProxies as jest.Mock).mockReturnValueOnce({
15-
proxiesList: [
16-
{
17-
country: 'Albania',
18-
},
19-
{
20-
country: 'Australia',
21-
},
22-
],
23-
});
24-
2529
const wrapper = mount(Location);
2630
await wrapper.vm.$nextTick();
2731

src/composables/useActiveTab.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ const activeTabHost = ref('');
44
const isAboutPage = ref(false);
55

66
const getActiveTab = async () => {
7-
try {
8-
const activeWindow = await browser.windows.getCurrent({ populate: true });
9-
const activeTab = activeWindow.tabs!.find((tab) => tab.active);
7+
const activeWindow = await browser.windows.getCurrent({ populate: true });
8+
const activeTab = activeWindow.tabs!.find((tab) => tab.active);
109

11-
const activeTabURL = new URL(activeTab!.url!);
12-
activeTabHost.value = activeTabURL.hostname;
13-
isAboutPage.value = activeTabURL.protocol === 'about:';
14-
} catch (error) {
15-
console.log('No active tab found');
16-
}
10+
const activeTabURL = new URL(activeTab!.url!);
11+
activeTabHost.value = activeTabURL.hostname;
12+
isAboutPage.value = activeTabURL.protocol === 'about:';
1713
};
1814

1915
const useActiveTab = () => {

0 commit comments

Comments
 (0)