From a5656c0b1097978c44e34f555fbac6d046242e19 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 16 Jan 2021 13:47:15 +0800 Subject: [PATCH] test: generate _sidebar.md --- e2e/commands/generate.test.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 e2e/commands/generate.test.js diff --git a/e2e/commands/generate.test.js b/e2e/commands/generate.test.js new file mode 100644 index 0000000..7c7e1e8 --- /dev/null +++ b/e2e/commands/generate.test.js @@ -0,0 +1,28 @@ +const test = require('ava') +const fs = require('fs') +const path = require('path') + +const {run} = require('../helpers/test-utils.js') + +const genPath = path.join(__dirname, 'generate-cmd') +const docsPath = path.join(genPath, 'docs') + +test.before('create temp directory', () => { + // Cleanup if the directory already exists + if (fs.existsSync(genPath)) { + fs.rmdirSync(genPath, {recursive: true}) + } + + fs.mkdirSync(genPath) +}) + +test.after('cleanup', () => { + fs.rmdirSync(genPath, {recursive: true}) +}) + +test('generate _sidebar.md', t => { + run(['init', 'docs'], {cwd: genPath}) + run(['generate', 'docs'], {cwd: genPath}) + // Check for existence + t.true(fs.existsSync(path.join(docsPath, '_sidebar.md'))) +})