Skip to content

Commit

Permalink
Test that data attributes take precendence over JS config
Browse files Browse the repository at this point in the history
  • Loading branch information
romaricpascal committed Sep 20, 2022
1 parent 413248d commit 01d2304
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/govuk/components/button/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('/components/button', () => {
}

describe('not enabled', () => {
it('does not prevent multiple submissions when feature', async () => {
it('does not prevent multiple submissions', async () => {
await page.goto(baseUrl + '/components/button/preview', {
waitUntil: 'load'
})
Expand Down Expand Up @@ -209,6 +209,27 @@ describe('/components/button', () => {
})
})

describe('using JavaScript configuration, but cancelled by data-attributes', () => {
it('does not prevent multiple submissions', async () => {
await renderAndInitialise('button', {
baseUrl,
nunjucksParams: examples["don't prevent double click"],
javascriptConfig: {
preventDoubleClick: true
}
})

await trackClicks()

await page.click('button')
await page.click('button')

const clicksCount = await getClicksCount()

expect(clicksCount).toBe(2)
})
})

describe('using `initAll`', () => {
// To ensure
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/govuk/components/button/button.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ examples:
hidden: true
data:
text: Submit
- name: "don't prevent double click"
- name: don't prevent double click
hidden: true
data:
text: Submit
Expand Down

0 comments on commit 01d2304

Please sign in to comment.