2022-05-12 09:29:55 +00:00
|
|
|
import { expect, it } from 'vitest'
|
2022-11-29 10:18:58 +00:00
|
|
|
import { screen } from '@testing-library/vue'
|
2022-05-12 09:29:55 +00:00
|
|
|
import { $ } from '@/utils'
|
2022-05-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-05-12 09:29:55 +00:00
|
|
|
import BtnScrollToTop from './BtnScrollToTop.vue'
|
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-05-12 09:29:55 +00:00
|
|
|
protected test () {
|
|
|
|
it('renders', () => {
|
|
|
|
expect(this.render(BtnScrollToTop).html()).toMatchSnapshot()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('scrolls to top', async () => {
|
|
|
|
const mock = this.mock($, 'scrollTo')
|
2022-11-29 10:18:58 +00:00
|
|
|
this.render(BtnScrollToTop)
|
2022-05-12 09:29:55 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
await this.user.click(screen.getByTitle('Scroll to top'))
|
2022-05-12 09:29:55 +00:00
|
|
|
|
|
|
|
expect(mock).toHaveBeenCalled()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|