koel/resources/assets/js/components/layout/app-footer/FooterQueueButton.spec.ts

31 lines
853 B
TypeScript
Raw Normal View History

2024-06-03 09:29:58 +00:00
import { screen } from '@testing-library/vue'
import { expect, it } from 'vitest'
import UnitTestCase from '@/__tests__/UnitTestCase'
import Router from '@/router'
import Component from './FooterQueueButton.vue'
new class extends UnitTestCase {
protected test () {
it('goes to queue screen', async () => {
const goMock = this.mock(Router, 'go')
this.render(Component)
await this.user.click(screen.getByRole('button'))
expect(goMock).toHaveBeenCalledWith('queue')
})
it('goes back if current screen is Queue', async () => {
this.router.$currentRoute.value = {
screen: 'Queue',
path: '/queue'
}
const goMock = this.mock(Router, 'go')
this.render(Component)
await this.user.click(screen.getByRole('button'))
expect(goMock).toHaveBeenCalledWith(-1)
})
}
}