Verified Commit 0b34c7df authored by Aral Balkan's avatar Aral Balkan
Browse files

Add unit tests for generic Hugo command() method

parent a614da85
node_modules
test/public/**
test/a-new-site/**
......@@ -24,7 +24,37 @@ async function httpGet (url) {
})
}
test('[hugo-build] ', async t => {
test('[hugo.command]', async t => {
t.plan(4)
const sourcePath = 'test/a-new-site'
if (fs.existsSync(sourcePath)) {
fs.removeSync(sourcePath)
}
const args = `new site ${sourcePath}`
let hasError = false
let output = null
try {
// Tell the built-in Hugo binary to create a new site at ./my-new-site/.
output = await hugo.command(args)
} catch (error) {
hasError = true
}
t.false(hasError, 'does not throw an error')
t.true(output.includes('Congratulations! Your new Hugo site is created'), 'new site is generated')
t.true(fs.existsSync(sourcePath), 'generated site exists where we expect it')
const generatedFiles = fs.readdirSync(sourcePath)
t.true(generatedFiles.join(',') === 'archetypes,config.toml,content,data,layouts,static,themes', 'contents of generated site are as expected')
})
test('[hugo.build] ', async t => {
t.plan(3)
const sourcePath = 'test/site'
......@@ -59,7 +89,7 @@ test('[hugo-build] ', async t => {
})
test('[hugo-serve] ', async t => {
test('[hugo.serve] ', async t => {
t.plan(5)
const sourcePath = 'test/site'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment