25 lines
672 B
TypeScript
25 lines
672 B
TypeScript
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import BaseModal from '../BaseModal.vue'
|
|
|
|
describe('BaseModal', () => {
|
|
afterEach(() => {
|
|
document.body.style.overflow = ''
|
|
})
|
|
|
|
it('locks page scroll while open and restores it when closed', async () => {
|
|
const wrapper = mount(BaseModal, {
|
|
props: { show: true, title: 'Test modal' },
|
|
slots: { default: '<p>Modal content</p>' },
|
|
attachTo: document.body,
|
|
})
|
|
|
|
expect(document.body.style.overflow).toBe('hidden')
|
|
|
|
await wrapper.setProps({ show: false })
|
|
expect(document.body.style.overflow).toBe('')
|
|
|
|
wrapper.unmount()
|
|
})
|
|
})
|