From d72d00ad16eaffe2dca1f19d61a23eb4c08f73d9 Mon Sep 17 00:00:00 2001 From: Ben Surgison Date: Mon, 20 Mar 2023 21:53:12 +0000 Subject: [PATCH] Fix tests --- migrator/migration-steps.js | 3 +++ migrator/migration-steps.spec.js | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/migrator/migration-steps.js b/migrator/migration-steps.js index 14058f84c8..03d601d093 100644 --- a/migrator/migration-steps.js +++ b/migrator/migration-steps.js @@ -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') { @@ -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 } } diff --git a/migrator/migration-steps.spec.js b/migrator/migration-steps.spec.js index 7ea4ae3a96..134f783e09 100644 --- a/migrator/migration-steps.spec.js +++ b/migrator/migration-steps.spec.js @@ -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') @@ -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)