mirror of
https://github.com/koel/koel
synced 2024-12-20 09:33:23 +00:00
27 lines
783 B
TypeScript
27 lines
783 B
TypeScript
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
import factory from '@/__tests__/factory'
|
|
import { expect, it } from 'vitest'
|
|
import { eventBus } from '@/utils'
|
|
import { screen } 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 emitMock = this.mock(eventBus, 'emit')
|
|
this.renderComponent()
|
|
|
|
await this.user.click(screen.getByRole('button', { name: 'Log out' }))
|
|
|
|
expect(emitMock).toHaveBeenCalledWith('LOG_OUT')
|
|
})
|
|
}
|
|
}
|