File tree 2 files changed +22
-22
lines changed
2 files changed +22
-22
lines changed Original file line number Diff line number Diff line change @@ -2,26 +2,30 @@ import { mount } from '@vue/test-utils';
2
2
import { NCollapseItem } from 'naive-ui' ;
3
3
4
4
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
+ } ) ) ;
6
12
7
13
jest . mock ( '@/composables/useListProxies' , ( ) => ( {
8
14
__esModule : true ,
9
- default : jest . fn ( ) ,
15
+ default : jest . fn ( ( ) => ( {
16
+ proxiesList : [
17
+ {
18
+ country : 'Albania' ,
19
+ } ,
20
+ {
21
+ country : 'Australia' ,
22
+ } ,
23
+ ] ,
24
+ } ) ) ,
10
25
} ) ) ;
11
26
12
27
describe ( 'Location' , ( ) => {
13
28
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
-
25
29
const wrapper = mount ( Location ) ;
26
30
await wrapper . vm . $nextTick ( ) ;
27
31
Original file line number Diff line number Diff line change @@ -4,16 +4,12 @@ const activeTabHost = ref('');
4
4
const isAboutPage = ref ( false ) ;
5
5
6
6
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 ) ;
10
9
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:' ;
17
13
} ;
18
14
19
15
const useActiveTab = ( ) => {
You can’t perform that action at this time.
0 commit comments