From 1026ab9cc72b5c7397543425aadd2af747b30be2 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sun, 1 Nov 2020 23:57:27 +0530 Subject: [PATCH] tests: remove stale helper --- lib/cli/test/commands/init.test.js | 48 +++++++++++++++--------------- lib/cli/test/default/cli.test.js | 2 +- lib/cli/test/helpers.js | 32 +------------------- 3 files changed, 26 insertions(+), 56 deletions(-) diff --git a/lib/cli/test/commands/init.test.js b/lib/cli/test/commands/init.test.js index b34bcab6642b..3d1095ffa795 100644 --- a/lib/cli/test/commands/init.test.js +++ b/lib/cli/test/commands/init.test.js @@ -2,7 +2,7 @@ const fs = require('fs'); const fse = require('fs-extra'); const path = require('path'); -const { run } = require('../helpers'); +const run = require('../helpers'); const fixturesDirPath = path.join(__dirname, '..', 'fixtures'); const runDirPath = path.join(__dirname, '..', 'run'); @@ -26,28 +26,28 @@ afterAll(() => { describe('sb init', () => { it('starts storybook without errors', () => { - // const dirs = fs.readdirSync(runDirPath).filter((dir) => !dir.includes('vue')); - // dirs.forEach((dir) => { - // run(['init', '--skip-install', 'yes'], { cwd: path.join(runDirPath, dir) }); - // }); - // - // // Install all the dependencies in a single run - // console.log('Running bootstrap'); - // run( - // ['yarn', 'install', '--non-interactive', '--silent', '--pure-lockfile'], - // { cwd: rootPath }, - // false - // ); - // - // // Check that storybook starts without errors - // dirs.forEach((dir) => { - // console.log(`Running smoke test in ${dir}`); - // const { status } = run( - // ['yarn', 'storybook', '--smoke-test', '--quiet'], - // { cwd: path.join(runDirPath, dir) }, - // false - // ); - // expect(status).toBe(0); - // }); + const dirs = fs.readdirSync(runDirPath).filter((dir) => !dir.includes('vue')); + dirs.forEach((dir) => { + run(['init', '--skip-install', 'yes'], { cwd: path.join(runDirPath, dir) }); + }); + + // Install all the dependencies in a single run + console.log('Running bootstrap'); + run( + ['yarn', 'install', '--non-interactive', '--silent', '--pure-lockfile'], + { cwd: rootPath }, + false + ); + + // Check that storybook starts without errors + dirs.forEach((dir) => { + console.log(`Running smoke test in ${dir}`); + const { status } = run( + ['yarn', 'storybook', '--smoke-test', '--quiet'], + { cwd: path.join(runDirPath, dir) }, + false + ); + expect(status).toBe(0); + }); }); }); diff --git a/lib/cli/test/default/cli.test.js b/lib/cli/test/default/cli.test.js index 9043a9220147..5645aa702858 100755 --- a/lib/cli/test/default/cli.test.js +++ b/lib/cli/test/default/cli.test.js @@ -1,4 +1,4 @@ -const { run } = require('../helpers'); +const run = require('../helpers'); describe('Default behavior', () => { it('suggests the closest match to an unknown command', () => { diff --git a/lib/cli/test/helpers.js b/lib/cli/test/helpers.js index fd10b2a94556..b88ddccace4f 100644 --- a/lib/cli/test/helpers.js +++ b/lib/cli/test/helpers.js @@ -1,36 +1,9 @@ const { sync: spawnSync } = require('cross-spawn'); const fs = require('fs'); -const fse = require('fs-extra'); const path = require('path'); const CLI_PATH = path.join(__dirname, '..', 'bin'); -/** - * Copy directory content recursively - * @param {String} source - source directory path - * @param {String} target - path to the destination directory - * @returns {Void} - */ -const copyDirSync = (source, target) => { - // check if folder needs to be created or integrated - const targetFolder = path.join(target, path.basename(source)); - if (!fs.existsSync(targetFolder)) { - fs.mkdirSync(targetFolder); - } - - // copy - if (fs.lstatSync(source).isDirectory()) { - fs.readdirSync(source).forEach((file) => { - const curSource = path.join(source, file); - if (fs.lstatSync(curSource).isDirectory()) { - copyDirSync(curSource, targetFolder); - } else { - fse.copySync(curSource, targetFolder); - } - }); - } -}; - /** * Execute command * @param {String[]} args - args to be passed in @@ -40,7 +13,4 @@ const copyDirSync = (source, target) => { const run = (args, options = {}, cli = true) => spawnSync(cli ? 'node' : args[0], cli ? [CLI_PATH].concat(args) : args.slice(1), options); -module.exports = { - copyDirSync, - run, -}; +module.exports = run;