Skip to content

Commit

Permalink
WIP add Jasmine test for autocomplete
Browse files Browse the repository at this point in the history
This isn't working but I'm not entirely sure how to work out why given
the complicated govuk-docker setup. I'm unlikely to have time to look
into this properly in the short term

Leaving it as a WIP, but it's possible that we don't need this? I'm not
sure what our approach is to testing custom JavaScript (the autocomplete
is mostly from a library, but with some customisation)
  • Loading branch information
yndajas committed Feb 15, 2024
1 parent 7d40732 commit 306ee4f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions spec/javascripts/modules/add-permissions-with-autocomplete-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// describe('GOVUK.Modules.AccessibleAutocomplete', function () {
// let component, module

// beforeEach(function () {
// component = document.createElement('div')
// component.setAttribute('data-module', 'accessible-autocomplete')
// component.innerHTML = `
// <label class="govuk-label govuk-label--m" for="new_permission_id">Add a permission</label>

// <div id="hint-1234" class="gem-c-hint govuk-hint">
// Search for the permission you want to add.

// <select name="application[new_permission_id]" id="new_permission_id" class="govuk-select" aria-describedby="hint-1234">
// <option value=""></option>
// <option value="1">permission-1</option>
// <option value="2">permission-2</option>
// <option value="3">permission-3</option>
// <option value="4">permission-4</option>
// <option value="5">permission-5</option>
// <option value="6">permission-6</option>
// <option value="7">permission-7</option>
// <option value="8">permission-8</option>
// <option value="9">permission-9</option>
// </select>
// </div>
// `
// module = new GOVUK.Modules.AccessibleAutocomplete(component)
// module.init()
// })

// it('updates the value of the select element when selected via the autocomplete element', function () {
// const autocompleteInput = component.querySelector('.autocomplete__input')
// autocompleteInput.value = 'per'

// // not found
// const firstAutocompleteListItem = component.querySelector('#new_permission_id__option--0')
// firstAutocompleteListItem.click()

// const selectInput = component.querySelector('select')
// expect(selectInput.value).toBe(1)
// })

// // it('resets the value of the select element when the value of the autocomplete element no longer matches', function () {

// // })

// // it('clears the value of the select and autocomplete elements when clicking the clear button', function () {

// // })
// })

0 comments on commit 306ee4f

Please sign in to comment.