Add test coverage for assets/app.js
- Test that initMobileMenu and initTabs are called on DOMContentLoaded Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
26
tests/js/app.test.js
Normal file
26
tests/js/app.test.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
vi.mock('../../assets/modules/mobile-menu.js', () => ({
|
||||
initMobileMenu: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('../../assets/modules/tabs.js', () => ({
|
||||
initTabs: vi.fn(),
|
||||
}))
|
||||
|
||||
import { initMobileMenu } from '../../assets/modules/mobile-menu.js'
|
||||
import { initTabs } from '../../assets/modules/tabs.js'
|
||||
|
||||
describe('app.js', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('calls initMobileMenu and initTabs on DOMContentLoaded', async () => {
|
||||
await import('../../assets/app.js')
|
||||
document.dispatchEvent(new Event('DOMContentLoaded'))
|
||||
|
||||
expect(initMobileMenu).toHaveBeenCalled()
|
||||
expect(initTabs).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user