Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
This test fails with:

```
Character count › when JavaScript is available › when counting characters › when the ID starts with a number › still works correctly

    DOMException: Failed to execute 'querySelector' on 'Element': '[id=1_more-detail-info]' is not a valid selector.
```

which matches the console error reported in the issue [1]

[1]: #2058
  • Loading branch information
36degrees committed Dec 18, 2020
1 parent 89c3400 commit ac7a5fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/govuk/components/character-count/character-count.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ describe('Character count', () => {
expect(ariaHidden).toBeFalsy()
})
})

describe('when the ID starts with a number', () => {
it('still works correctly', async () => {
await goToExample('with-id-starting-with-number')

const message = await page.$eval('.govuk-character-count__message', el => el.innerHTML.trim())

expect(message).toEqual('You have 10 characters remaining')
})
})
})

describe('when counting words', () => {
Expand Down
8 changes: 8 additions & 0 deletions src/govuk/components/character-count/character-count.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,11 @@ examples:
classes: app-character-count--custom-modifier
errorMessage:
text: Error message
- name: with id starting with number
hidden: true
data:
name: more-detail
id: 1_more-detail
maxlength: 10
label:
text: Can you provide more detail?

0 comments on commit ac7a5fe

Please sign in to comment.