mirror of
https://github.com/koel/koel
synced 2024-12-21 10:03:10 +00:00
28 lines
771 B
TypeScript
28 lines
771 B
TypeScript
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||
|
import factory from '@/__tests__/factory'
|
||
|
import { expect, it } from 'vitest'
|
||
|
import { eventBus } from '@/utils'
|
||
|
import { fireEvent } from '@testing-library/vue'
|
||
|
import UserBadge from './UserBadge.vue'
|
||
|
|
||
|
new class extends UnitTestCase {
|
||
|
private renderComponent () {
|
||
|
return this.actingAs(factory<User>('user', {
|
||
|
name: 'John Doe'
|
||
|
})).render(UserBadge)
|
||
|
}
|
||
|
|
||
|
protected test () {
|
||
|
it('renders', () => expect(this.renderComponent().html()).toMatchSnapshot())
|
||
|
|
||
|
it('logs out', async () => {
|
||
|
const mock = this.mock(eventBus, 'emit')
|
||
|
const { getByTestId } = this.renderComponent()
|
||
|
|
||
|
await fireEvent.click(getByTestId('btn-logout'))
|
||
|
|
||
|
expect(mock).toHaveBeenCalledOnce()
|
||
|
})
|
||
|
}
|
||
|
}
|