Skip to content

Commit

Permalink
Export createAll function in all.mjs
Browse files Browse the repository at this point in the history
Move the `components/global.puppeteer.test.js` file up to `all.puppeteer.test.js`
as it's more related to the `all.mjs` file than the components themselves.

Co-authored-by: Oliver Byford <[email protected]>
  • Loading branch information
romaricpascal and 36degrees committed May 9, 2024
1 parent b53ae4e commit c5a3989
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/govuk-frontend/src/govuk/all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import { PasswordInput } from './components/password-input/password-input.mjs'
import { Radios } from './components/radios/radios.mjs'
import { SkipLink } from './components/skip-link/skip-link.mjs'
import { Tabs } from './components/tabs/tabs.mjs'
import { initAll } from './init.mjs'
import { initAll, createAll } from './init.mjs'

export {
initAll,
createAll,
version,

// Components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,24 @@ describe('GOV.UK Frontend', () => {
expect(typeofInitAll).toBe('function')
})

it('exports `createAll` function', async () => {
const typeofCreateAll = await page.evaluate(
async (importPath, exportName) => {
const namespace = await import(importPath)
return typeof namespace[exportName]
},
scriptsPath.href,
'createAll'
)

expect(typeofCreateAll).toBe('function')
})

it('exports Components', async () => {
const components = exported
.filter((method) => !['initAll', 'version'].includes(method))
.filter(
(method) => !['initAll', 'createAll', 'version'].includes(method)
)
.sort()

// Ensure GOV.UK Frontend exports the expected components
Expand Down

0 comments on commit c5a3989

Please sign in to comment.