Skip to content

Commit 200f0e8

Browse files
Add coverage for index.js
1 parent 2e9fdba commit 200f0e8

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { waitFor } from '@testing-library/dom'
2+
3+
import { initCheckIn } from './check-in.js'
4+
5+
jest.mock('./check-in.js')
6+
7+
describe('Automatic initialisation', () => {
8+
it('should init components on DOMContentLoaded', async () => {
9+
await import('./index.js')
10+
11+
// Should not initialise on import
12+
expect(initCheckIn).not.toHaveBeenCalled()
13+
14+
// Should initialise on DOMContentLoaded
15+
window.document.dispatchEvent(new Event('DOMContentLoaded'))
16+
await waitFor(() => expect(initCheckIn).toHaveBeenCalled())
17+
})
18+
})

manage_breast_screening/assets/js/set-submit.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { userEvent } from '@testing-library/user-event'
33

44
import setSubmit from './set-submit.js'
55

6-
describe('setSubmit', () => {
6+
describe('Set submit events', () => {
77
const user = userEvent.setup()
88

99
/** @type {HTMLButtonElement} */

0 commit comments

Comments
 (0)