Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to actually invoke the desired method instead of replicating it #53

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update tests to actually invoke the desired method instead of replica…
…ting it
  • Loading branch information
JamesMGreene committed Jan 31, 2023
commit 9b358e73bb4d7df45487b51bb1d116f8c786fae6
26 changes: 11 additions & 15 deletions src/set-pages-config.test.js
Original file line number Diff line number Diff line change
@@ -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
@@ -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(
@@ -71,7 +70,7 @@ describe('configParser', () => {
)}.expected${defaultFileExtension}`

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

@@ -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)
})
})
})