Skip to content

Commit

Permalink
Add more complex application.js to test
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Apr 4, 2023
1 parent c6a064c commit 40f2d4e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

### New features

- [#2049: Migrate changed application.js if possible](https://github.com/alphagov/govuk-prototype-kit/pull/2049)
Converts the application.js file if possible during migration

- [#2079: Migrate changed filters if possible](https://github.com/alphagov/govuk-prototype-kit/pull/2079)
Converts the filters.js file if possible during migration
- [#2049: Migrate changed files if possible](https://github.com/alphagov/govuk-prototype-kit/pull/2049)
Converts the following files if possible during migration:
- application.js
- filters.js

## 13.5.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
/* global $ */
/* global GOVUK */

// Warn about using the kit in production
if (window.console && window.console.info) {
window.console.info('GOV.UK Prototype Kit - do not use for production')
}

$(document).ready(function () {
window.GOVUKFrontend.initAll()
console.log('Hello')
// Use GOV.UK shim-links-with-button-role.js to trigger a link styled to look like a button,
// with role="button" when the space key is pressed.
GOVUK.shimLinksWithButtonRole.init()

// Details/summary polyfill from frontend toolkit
GOVUK.details.init()

// Show and hide toggled content
// Where .multiple-choice uses the data-target attribute
// to toggle hidden content
var showHideContent = new GOVUK.ShowHideContent()
showHideContent.init()
})
18 changes: 16 additions & 2 deletions __tests__/spec/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,27 @@ describe('migrate test prototype', () => {
it('application.js should be overwritten', () => {
const jsFileContents = getNormalisedFileContent(path.join(assetsDirectory, 'javascripts', 'application.js'))

expect(jsFileContents).toEqual(`//
expect(jsFileContents).toEqual(`/* global GOVUK */
//
// For guidance on how to add JavaScript see:
// https://prototype-kit.service.gov.uk/docs/adding-css-javascript-and-images
//
window.GOVUKPrototypeKit.documentReady(function () {
console.log('Hello')
// Use GOV.UK shim-links-with-button-role.js to trigger a link styled to look like a button,
// with role="button" when the space key is pressed.
GOVUK.shimLinksWithButtonRole.init()
// Details/summary polyfill from frontend toolkit
GOVUK.details.init()
// Show and hide toggled content
// Where .multiple-choice uses the data-target attribute
// to toggle hidden content
var showHideContent = new GOVUK.ShowHideContent()
showHideContent.init()
})
`)
})
Expand Down
14 changes: 0 additions & 14 deletions migrator/update-application-js-step.spec.js

This file was deleted.

0 comments on commit 40f2d4e

Please sign in to comment.