Skip to content

Commit fcafbda

Browse files
committed
Update NavBar unit tests
1 parent 400e1b7 commit fcafbda

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

frontend/test/components/NavBar.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import withSetup from '../utils/with-setup';
77
import { useUserStore } from '@/stores/user-store';
88
import { RouterLink } from 'vue-router';
99
import NavBar from '@/components/NavBar.vue';
10-
import { accountsTbProfileUrlKey } from '@/keys';
1110

1211

1312
describe('NavBar', () => {
1413
var app;
1514
var wrapper;
16-
const testAccountsTbProfileUrl = 'https://accounts.tb.pro/dashboard';
1715

1816
// list of route names that are also lang keys (format: label.<key>), used as nav items
1917
// these routes are added in addition to the routes already specified in NavBar.vue
@@ -29,9 +27,6 @@ describe('NavBar', () => {
2927
propsData: ourProps,
3028
global: {
3129
plugins: [i18ninstance, router],
32-
provide: {
33-
[accountsTbProfileUrlKey]: testAccountsTbProfileUrl,
34-
},
3530
},
3631
});
3732

@@ -57,7 +52,7 @@ describe('NavBar', () => {
5752
expect(foundLinks[0]['name'], 'expected link component to be rendered').toBe('home');
5853
});
5954

60-
it('renders correctly when logged in', () => {
55+
it('renders correctly when logged in', async () => {
6156
// fake sign-in via user store
6257
const user = useUserStore();
6358
user.data.accessToken = 'abc';
@@ -79,8 +74,12 @@ describe('NavBar', () => {
7974
expect(foundLinks, 'expected link component to be rendered').toContain(expRoute);
8075
}
8176

77+
// open the user menu dropdown by clicking the avatar
78+
const userAvatar = wrapper.find('.user-menu .avatar');
79+
await userAvatar.trigger('click');
80+
8281
// verify the anchor tag to accountsTbProfileUrl exists and has the correct href
83-
const profileAnchor = wrapper.find('a[href="' + testAccountsTbProfileUrl + '"]');
82+
const profileAnchor = wrapper.find(`a[href="${import.meta.env.VITE_TB_ACCOUNT_DASHBOARD_URL}"]`);
8483
expect(profileAnchor.exists(), 'expected anchor tag to accountsTbProfileUrl to be rendered').toBe(true);
8584
});
8685

frontend/test/components/NavBarMobile.test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@ import withSetup from '../utils/with-setup';
77
import { useUserStore } from '@/stores/user-store';
88
import { RouterLink } from 'vue-router';
99
import NavBarMobile from '@/components/NavBarMobile.vue';
10-
import { accountsTbProfileUrlKey } from '@/keys';
1110

1211

1312
describe('NavBarMobile', () => {
1413
var app;
1514
var wrapper;
16-
const testAccountsTbProfileUrl = 'https://accounts.tb.pro/dashboard';
1715

1816
const getMountOptions = () => ({
1917
global: {
2018
plugins: [i18ninstance, router],
21-
provide: {
22-
[accountsTbProfileUrlKey]: testAccountsTbProfileUrl,
23-
},
2419
},
2520
});
2621

@@ -83,8 +78,6 @@ describe('NavBarMobile', () => {
8378
'bookings',
8479
'availability',
8580
'settings',
86-
'report-bug',
87-
'contact',
8881
'logout'
8982
];
9083

@@ -103,7 +96,7 @@ describe('NavBarMobile', () => {
10396
}
10497

10598
// verify the anchor tag to accountsTbProfileUrl exists and has the correct href
106-
const profileAnchor = wrapper.find('a[href="' + testAccountsTbProfileUrl + '"]');
99+
const profileAnchor = wrapper.find(`a[href="${import.meta.env.VITE_TB_ACCOUNT_DASHBOARD_URL}"]`);
107100
expect(profileAnchor.exists(), 'expected anchor tag to accountsTbProfileUrl to be rendered').toBe(true);
108101
});
109102

0 commit comments

Comments
 (0)