Skip to content

Commit

Permalink
tests: remove stale helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Nov 1, 2020
1 parent ba3bf71 commit 1026ab9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 56 deletions.
48 changes: 24 additions & 24 deletions lib/cli/test/commands/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
});
});
});
2 changes: 1 addition & 1 deletion lib/cli/test/default/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { run } = require('../helpers');
const run = require('../helpers');

describe('Default behavior', () => {
it('suggests the closest match to an unknown command', () => {
Expand Down
32 changes: 1 addition & 31 deletions lib/cli/test/helpers.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

0 comments on commit 1026ab9

Please sign in to comment.