We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1d32e4d commit 5daf5fbCopy full SHA for 5daf5fb
packages/nhsuk.jsdom.test.mjs
@@ -0,0 +1,20 @@
1
+import { waitFor } from '@testing-library/dom'
2
+
3
+import { initAll } from './index.js'
4
5
+jest.mock('./index.js')
6
7
+describe('NHS.UK frontend', () => {
8
+ describe('Automatic initialisation', () => {
9
+ it('should init components on DOMContentLoaded', async () => {
10
+ await import('./nhsuk.js')
11
12
+ // Should not initialise on import
13
+ expect(initAll).not.toHaveBeenCalled()
14
15
+ // Should initialise on DOMContentLoaded
16
+ window.document.dispatchEvent(new Event('DOMContentLoaded'))
17
+ await waitFor(() => expect(initAll).toHaveBeenCalled())
18
+ })
19
20
+})
0 commit comments