Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support beforeInitialisation() options, multiple modules #4330

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ describe('/components/accordion', () => {
})

it('injects the localised strings as text not HTML', async () => {
await renderAndInitialise(page, 'accordion', {
params: examples.default,
await renderAndInitialise(page, 'accordion', examples.default, {
config: {
i18n: {
showAllSections: 'Show <strong>all sections</strong>',
Expand Down Expand Up @@ -722,8 +721,7 @@ describe('/components/accordion', () => {

it('throws when GOV.UK Frontend is not supported', async () => {
await expect(
renderAndInitialise(page, 'accordion', {
params: examples.default,
renderAndInitialise(page, 'accordion', examples.default, {
beforeInitialisation() {
document.body.classList.remove('govuk-frontend-supported')
}
Expand All @@ -736,8 +734,7 @@ describe('/components/accordion', () => {

it('throws when $module is not set', async () => {
await expect(
renderAndInitialise(page, 'accordion', {
params: examples.default,
renderAndInitialise(page, 'accordion', examples.default, {
beforeInitialisation($module) {
$module.remove()
}
Expand All @@ -750,8 +747,7 @@ describe('/components/accordion', () => {

it('throws when receiving the wrong type for $module', async () => {
await expect(
renderAndInitialise(page, 'accordion', {
params: examples.default,
renderAndInitialise(page, 'accordion', examples.default, {
beforeInitialisation($module) {
// Replace with an `<svg>` element which is not an `HTMLElement` in the DOM (but an `SVGElement`)
$module.outerHTML = `<svg data-module="govuk-accordion"></svg>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ describe('/components/button', () => {
let $button

beforeEach(async () => {
await renderAndInitialise(page, 'button', {
params: examples.default,
await renderAndInitialise(page, 'button', examples.default, {
config: {
preventDoubleClick: true
}
Expand Down Expand Up @@ -238,12 +237,16 @@ describe('/components/button', () => {
let $button

beforeEach(async () => {
await renderAndInitialise(page, 'button', {
params: examples["don't prevent double click"],
config: {
preventDoubleClick: true
await renderAndInitialise(
page,
'button',
examples["don't prevent double click"],
{
config: {
preventDoubleClick: true
}
}
})
)

$button = await setButtonTracking(await page.$('button'))
})
Expand All @@ -263,8 +266,7 @@ describe('/components/button', () => {
let $button

beforeEach(async () => {
await renderAndInitialise(page, 'button', {
params: examples.default,
await renderAndInitialise(page, 'button', examples.default, {
config: {
preventDoubleClick: true
}
Expand Down Expand Up @@ -327,8 +329,7 @@ describe('/components/button', () => {

it('throws when GOV.UK Frontend is not supported', async () => {
await expect(
renderAndInitialise(page, 'button', {
params: examples.default,
renderAndInitialise(page, 'button', examples.default, {
beforeInitialisation() {
document.body.classList.remove('govuk-frontend-supported')
}
Expand All @@ -341,8 +342,7 @@ describe('/components/button', () => {

it('throws when $module is not set', async () => {
await expect(
renderAndInitialise(page, 'button', {
params: examples.default,
renderAndInitialise(page, 'button', examples.default, {
beforeInitialisation($module) {
$module.remove()
}
Expand All @@ -355,8 +355,7 @@ describe('/components/button', () => {

it('throws when receiving the wrong type for $module', async () => {
await expect(
renderAndInitialise(page, 'button', {
params: examples.default,
renderAndInitialise(page, 'button', examples.default, {
beforeInitialisation($module) {
// Replace with an `<svg>` element which is not an `HTMLElement` in the DOM (but an `SVGElement`)
$module.outerHTML = `<svg data-module="govuk-button"></svg>`
Expand Down
Loading