Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Jul 9, 2024
1 parent 3217cd6 commit 29623e3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/javascripts/live_search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,27 @@ describe('liveSearch', function () {

expect(window.GOVUK.analyticsGa4.Ga4FinderTracker.trackChangeEvent).not.toHaveBeenCalled()
})

it('reinitialises tracking when search is updated', function () {
spyOn(liveSearch, 'reinitialiseGa4Tracking')
spyOn(liveSearch, 'restartGa4EcommerceTracking')

expect(liveSearch.reinitialiseGa4Tracking).not.toHaveBeenCalled()
expect(liveSearch.restartGa4EcommerceTracking).not.toHaveBeenCalled()

var $input = $form.find('input[name="field"]')
$input.attr('data-ga4-change-category', 'update-sort select')

liveSearch.state = []

liveSearch.formChange({ target: $input[0] })
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
response: '{"total":81,"display_total":"81 reports","facet_tags":"","search_results":"","display_selected_facets_count":"","sort_options_markup":"","next_and_prev_links":"","suggestions":"","errors":{}}'
})

expect(liveSearch.reinitialiseGa4Tracking).toHaveBeenCalled()
})
})

describe('meta tag updating', function () {
Expand Down

0 comments on commit 29623e3

Please sign in to comment.