2022-12-07 13:31:38 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import { screen } from '@testing-library/vue'
|
|
|
|
import { faHome } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import SidebarItem from './SidebarItem.vue'
|
|
|
|
|
|
|
|
new class extends UnitTestCase {
|
|
|
|
private renderComponent () {
|
|
|
|
return this.render(SidebarItem, {
|
|
|
|
props: {
|
|
|
|
icon: faHome,
|
|
|
|
href: '#',
|
|
|
|
screen: 'Home'
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: 'Home'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-08-20 22:35:58 +00:00
|
|
|
protected test () {
|
2022-12-07 13:31:38 +00:00
|
|
|
it('renders', () => expect(this.renderComponent().html()).toMatchSnapshot())
|
|
|
|
|
|
|
|
it('activates when the screen matches', async () => {
|
|
|
|
this.renderComponent()
|
|
|
|
|
|
|
|
await this.router.activateRoute({
|
|
|
|
screen: 'Home',
|
2023-08-20 22:35:58 +00:00
|
|
|
path: '_'
|
2022-12-07 13:31:38 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
expect(screen.getByRole('link').classList.contains('active')).toBe(true)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|