-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { type UserData, useUserStore } from '@/stores/user' | |
|
||
import UserProfileButton from '../UserProfileButton.vue' | ||
|
||
// Test data | ||
const adminUser: UserData = { | ||
id: '2c0a153e-5e8c-11ee-8c99-0242ac120002', | ||
email: '[email protected]', | ||
|
@@ -24,6 +25,7 @@ const adminUser: UserData = { | |
|
||
describe.concurrent('UserProfileButton', () => { | ||
it('displays Login button without any user', async () => { | ||
// arrange: | ||
const { wrapper } = await setupMountedComponents( | ||
{ component: UserProfileButton }, | ||
{ | ||
|
@@ -34,14 +36,18 @@ describe.concurrent('UserProfileButton', () => { | |
} | ||
} | ||
) | ||
|
||
// act: nothing, only test rendering | ||
|
||
// assert: | ||
const loginButton = wrapper.findComponent('#login') | ||
expect(loginButton.exists()).toBe(true) | ||
const logoutButton = wrapper.findComponent('#profile') | ||
expect(logoutButton.exists()).toBe(false) | ||
}) | ||
|
||
it('displays Profile button with a user', async () => { | ||
// arrange: | ||
const { wrapper } = await setupMountedComponents( | ||
{ component: UserProfileButton }, | ||
{ | ||
|
@@ -53,13 +59,17 @@ describe.concurrent('UserProfileButton', () => { | |
} | ||
) | ||
|
||
// act: nothing, only test rendering | ||
|
||
// assert: | ||
const loginButton = wrapper.findComponent('#login') | ||
expect(loginButton.exists()).toBe(false) | ||
const logoutButton = wrapper.findComponent('#profile') | ||
expect(logoutButton.exists()).toBe(true) | ||
}) | ||
|
||
it('switches from Login to Profile button when store changes', async () => { | ||
// arrange: | ||
// Note that we use an `async` test here as we need `await nextTick()` for the DOM | ||
// update to bubble through when updating the state property. | ||
const { wrapper } = await setupMountedComponents( | ||
|
@@ -73,6 +83,7 @@ describe.concurrent('UserProfileButton', () => { | |
} | ||
) | ||
|
||
// act: | ||
let loginButton = wrapper.findComponent('#login') | ||
expect(loginButton.exists()).toBe(true) | ||
let logoutButton = wrapper.findComponent('#profile') | ||
|
@@ -83,6 +94,7 @@ describe.concurrent('UserProfileButton', () => { | |
|
||
await nextTick() | ||
|
||
// assert: | ||
loginButton = wrapper.findComponent('#login') | ||
expect(loginButton.exists()).toBe(false) | ||
logoutButton = wrapper.findComponent('#profile') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters