Skip to content

Commit

Permalink
Merge pull request #53 from actions/test-set-pages-config
Browse files Browse the repository at this point in the history
Update tests to actually invoke the desired method instead of replicating it
  • Loading branch information
JamesMGreene committed Feb 1, 2023
2 parents b8c94fd + 7eb7a15 commit 1d79de2
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/set-pages-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const fs = require('fs')
const path = require('path')
const core = require('@actions/core')

const { getConfigParserSettings } = require('./set-pages-config')
const { ConfigParser } = require('./config-parser')
const { setPagesConfig } = require('./set-pages-config')
const { getTempFolder, compareFiles } = require('./test-helpers')

// Get the temp folder
Expand Down Expand Up @@ -57,12 +56,12 @@ describe('configParser', () => {
fs.rmSync(fixtureTargetFile)
}

// Get settings for the static site generator
const settings = getConfigParserSettings({ staticSiteGenerator, siteUrl })
// Update the settings
settings.configurationFile = fixtureTargetFile
// Do the injection
new ConfigParser(settings).injectAll()
// Do the injections for the static site generator
setPagesConfig({
staticSiteGenerator,
generatorConfigFile: fixtureTargetFile,
siteUrl
})

// Read the expected file
const expectedFile = `${fixtureFolder}/${path.basename(
Expand All @@ -71,7 +70,7 @@ describe('configParser', () => {
)}.expected${defaultFileExtension}`

// Compare the actual and expected files
compareFiles(settings.configurationFile, expectedFile)
compareFiles(fixtureTargetFile, expectedFile)
})
})

Expand All @@ -90,24 +89,21 @@ describe('configParser', () => {
fs.rmSync(fixtureTargetFile)
}

// Get settings for the static site generator
const settings = getConfigParserSettings({
// Do the injections for the static site generator
setPagesConfig({
staticSiteGenerator,
generatorConfigFile: fixtureTargetFile,
siteUrl
})

// Do the injection
new ConfigParser(settings).injectAll()

// Read the expected file
const expectedFile = `${fixtureFolder}/${path.basename(
configurationFile,
fileExtension
)}.expected${fileExtension}`

// Compare the actual and expected files
compareFiles(settings.configurationFile, expectedFile)
compareFiles(fixtureTargetFile, expectedFile)
})
})
})
Expand Down

0 comments on commit 1d79de2

Please sign in to comment.