-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
43 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { mountSuspended } from '@nuxt/test-utils/runtime'; | ||
import UserBox from '~/components/home/Users/UserBox.vue'; // Replace with the actual path to your component | ||
|
||
describe('UserBox', () => { | ||
const props = { | ||
profilePicture: "https://example.com/profile.jpg", | ||
name: "Test User", | ||
userTurn: true, | ||
friendRequest: false, | ||
friendshipId: 1, | ||
friendsStatus: "PENDING", | ||
friendId: "123", | ||
viewType: 0, | ||
startGame: false, | ||
}; | ||
|
||
it('renders the user name correctly', async () => { | ||
const wrapper = await mountSuspended(UserBox, { props }); | ||
expect(wrapper.text()).toContain(props.name); | ||
}); | ||
|
||
it('displays the profile picture with the correct src', async () => { | ||
const wrapper = await mountSuspended(UserBox, { props }); | ||
const img = wrapper.find('img'); | ||
expect(img.attributes('src')).toBe(props.profilePicture); | ||
}); | ||
|
||
it('emits chose_friend when userTurn and startGame are true', async () => { | ||
const wrapper = await mountSuspended(UserBox, { | ||
props: { ...props, userTurn: true, startGame: true }, | ||
}); | ||
await wrapper.trigger('click'); | ||
expect(wrapper.emitted('chose_friend')).toBeTruthy(); | ||
Check failure on line 34 in components/__tests__/home/Users/UserBox.test.ts GitHub Actions / eslintcomponents/__tests__/home/Users/UserBox.test.ts > UserBox > emits chose_friend when userTurn and startGame are true
|
||
expect(wrapper.emitted('chose_friend')[0]).toEqual([props.friendId]); | ||
}); | ||
|
||
it('shows the modal when clicked and startGame is false', async () => { | ||
const wrapper = await mountSuspended(UserBox, { props }); | ||
await wrapper.trigger('click'); | ||
expect(wrapper.findComponent({ name: 'ProfileUserModal' }).isVisible()).toBe(true); | ||
}); | ||
}); |
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