Skip to content

Commit

Permalink
Remove unused error handling and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihildt committed Apr 18, 2024
1 parent 97da2f4 commit 2c64c80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
30 changes: 17 additions & 13 deletions src/components/Location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@ import { mount } from '@vue/test-utils';
import { NCollapseItem } from 'naive-ui';

import Location from '@/components/Location.vue';
import useListProxies from '@/composables/useListProxies';

jest.mock('@/composables/useActiveTab', () => ({
__esModule: true,
default: jest.fn(() => ({
activeTabHost: 'example.com',
})),
}));

jest.mock('@/composables/useListProxies', () => ({
__esModule: true,
default: jest.fn(),
default: jest.fn(() => ({
proxiesList: [
{
country: 'Albania',
},
{
country: 'Australia',
},
],
})),
}));

describe('Location', () => {
it('should show two countries', async () => {
(useListProxies as jest.Mock).mockReturnValueOnce({
proxiesList: [
{
country: 'Albania',
},
{
country: 'Australia',
},
],
});

const wrapper = mount(Location);
await wrapper.vm.$nextTick();

Expand Down
14 changes: 5 additions & 9 deletions src/composables/useActiveTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ const activeTabHost = ref('');
const isAboutPage = ref(false);

const getActiveTab = async () => {
try {
const activeWindow = await browser.windows.getCurrent({ populate: true });
const activeTab = activeWindow.tabs!.find((tab) => tab.active);
const activeWindow = await browser.windows.getCurrent({ populate: true });
const activeTab = activeWindow.tabs!.find((tab) => tab.active);

const activeTabURL = new URL(activeTab!.url!);
activeTabHost.value = activeTabURL.hostname;
isAboutPage.value = activeTabURL.protocol === 'about:';
} catch (error) {
console.log('No active tab found');
}
const activeTabURL = new URL(activeTab!.url!);
activeTabHost.value = activeTabURL.hostname;
isAboutPage.value = activeTabURL.protocol === 'about:';
};

const useActiveTab = () => {
Expand Down

0 comments on commit 2c64c80

Please sign in to comment.