Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Mar 20, 2023
1 parent 325fe2e commit d72d00a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions migrator/migration-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ async function upgradeIfPossible (filePath, matchFound) {
if (matchFound) {
return true
} else {
const reporter = await addReporter(`Update ${filePath}`)
const fullPath = path.join(projectDir, filePath)
const filename = fullPath.split(path.sep).pop()
if (filename === 'application.js') {
Expand Down Expand Up @@ -279,9 +280,11 @@ if (window.console && window.console.info) {
return currentContent.replace(originalText, replacementText || '')
}, fileBuffer.toString())
await fsp.writeFile(fullPath, content)
await reporter(true)
return true
}
}
await reporter(false)
return false
}
}
Expand Down
7 changes: 5 additions & 2 deletions migrator/migration-steps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ $(document).ready(function () {
`//
// For guidance on how to add JavaScript see:
// https://prototype-kit.service.gov.uk/docs/adding-css-javascript-and-images
//···
//
window.GOVUKPrototypeKit.documentReady(() => {
// Add JavaScript here
console.log('Hello')
Expand All @@ -390,7 +393,7 @@ window.GOVUKPrototypeKit.documentReady(() => {
expect(actualFileContent).toEqual(expectedFileContents)

expect(reporter.addReporter).toHaveBeenCalledTimes(1)
expect(reporter.addReporter).toHaveBeenCalledWith(`Overwrite ${applicationJsFile}`)
expect(reporter.addReporter).toHaveBeenCalledWith(`Update ${applicationJsFile}`)

expect(mockReporter).toHaveBeenCalledTimes(1)
expect(mockReporter).toHaveBeenCalledWith(true)
Expand Down

0 comments on commit d72d00a

Please sign in to comment.