@@ -7,11 +7,22 @@ import withSetup from '../utils/with-setup';
77import { useUserStore } from '@/stores/user-store' ;
88import { RouterLink } from 'vue-router' ;
99import NavBarMobile from '@/components/NavBarMobile.vue' ;
10+ import { accountsTbProfileUrlKey } from '@/keys' ;
1011
1112
1213describe ( 'NavBarMobile' , ( ) => {
1314 var app ;
1415 var wrapper ;
16+ const testAccountsTbProfileUrl = 'https://accounts.tb.pro/dashboard' ;
17+
18+ const getMountOptions = ( ) => ( {
19+ global : {
20+ plugins : [ i18ninstance , router ] ,
21+ provide : {
22+ [ accountsTbProfileUrlKey ] : testAccountsTbProfileUrl ,
23+ } ,
24+ } ,
25+ } ) ;
1526
1627 beforeEach ( ( ) => {
1728 app = withSetup ( ) ;
@@ -23,11 +34,7 @@ describe('NavBarMobile', () => {
2334 } ) ;
2435
2536 it ( 'renders correctly when not logged in' , ( ) => {
26- wrapper = mount ( NavBarMobile , {
27- global : {
28- plugins : [ i18ninstance , router ] ,
29- } ,
30- } ) ;
37+ wrapper = mount ( NavBarMobile , getMountOptions ( ) ) ;
3138
3239 // verify all expected router-link child components were rendered (only one when not signed in)
3340 const allRouterLinks = wrapper . findAllComponents ( RouterLink ) ;
@@ -45,11 +52,7 @@ describe('NavBarMobile', () => {
4552 user . data . accessToken = 'abc' ;
4653 expect ( user . authenticated ) . toBe ( true ) ;
4754
48- wrapper = mount ( NavBarMobile , {
49- global : {
50- plugins : [ i18ninstance , router ] ,
51- } ,
52- } ) ;
55+ wrapper = mount ( NavBarMobile , getMountOptions ( ) ) ;
5356
5457 // verify all expected router-link child components were rendered (only one when menu is closed)
5558 const allRouterLinks = wrapper . findAllComponents ( RouterLink ) ;
@@ -67,24 +70,19 @@ describe('NavBarMobile', () => {
6770 user . data . accessToken = 'abc' ;
6871 expect ( user . authenticated ) . toBe ( true ) ;
6972
70- wrapper = mount ( NavBarMobile , {
71- global : {
72- plugins : [ i18ninstance , router ] ,
73- } ,
74- } ) ;
73+ wrapper = mount ( NavBarMobile , getMountOptions ( ) ) ;
7574
7675 // click to open/show the menu
7776 const menuButton = wrapper . find ( 'button[aria-label="Open menu"]' ) ;
7877 await menuButton . trigger ( 'click' ) ;
7978
8079 // verify all expected router-link child components were rendered when signed in and menu is now shown
8180 const expectedLinks = [
82- 'dashboard' , // there are two dashboard rounter -link child components
81+ 'dashboard' , // there are two dashboard router -link child components
8382 'dashboard' ,
8483 'bookings' ,
8584 'availability' ,
8685 'settings' ,
87- 'profile' ,
8886 'report-bug' ,
8987 'contact' ,
9088 'logout'
@@ -103,6 +101,10 @@ describe('NavBarMobile', () => {
103101 for ( let expLink of expectedLinks ) {
104102 expect ( foundLinks , 'expected link component to be rendered' ) . toContain ( expLink ) ;
105103 }
104+
105+ // verify the anchor tag to accountsTbProfileUrl exists and has the correct href
106+ const profileAnchor = wrapper . find ( 'a[href="' + testAccountsTbProfileUrl + '"]' ) ;
107+ expect ( profileAnchor . exists ( ) , 'expected anchor tag to accountsTbProfileUrl to be rendered' ) . toBe ( true ) ;
106108 } ) ;
107109
108110 it ( 'able to click the copy link button' , async ( ) => {
@@ -121,11 +123,7 @@ describe('NavBarMobile', () => {
121123 user . myLink = 'https://stage.apt.mt/fakeuser/6e16a160/' ;
122124 expect ( user . authenticated ) . toBe ( true ) ;
123125
124- wrapper = mount ( NavBarMobile , {
125- global : {
126- plugins : [ i18ninstance , router ] ,
127- } ,
128- } ) ;
126+ wrapper = mount ( NavBarMobile , getMountOptions ( ) ) ;
129127
130128 // need to open the menu in order to access the copy link option
131129 const menuButton = wrapper . find ( 'button[aria-label="Open menu"]' ) ;
0 commit comments