Skip to content

Commit

Permalink
Merge pull request #103 from dthree/test-mock-column-width
Browse files Browse the repository at this point in the history
test: mock process.stdout.columns (fixes ls tests)
  • Loading branch information
nfischer committed Nov 14, 2016
2 parents e06eec5 + c989e4f commit 1f42d3b
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions dist/util/columnify.js
Expand Up @@ -48,6 +48,7 @@ module.exports = function (arr, options) {
} else {
// Pad the lines based on the
// longest word.
/* istanbul ignore next */
line += pad(arr[i], longest, ' ');
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/ls/dist/util/columnify.js
Expand Up @@ -48,6 +48,7 @@ module.exports = function (arr, options) {
} else {
// Pad the lines based on the
// longest word.
/* istanbul ignore next */
line += pad(arr[i], longest, ' ');
}
}
Expand Down
1 change: 1 addition & 0 deletions src/util/columnify.js
Expand Up @@ -50,6 +50,7 @@ module.exports = function (arr, options) {
} else {
// Pad the lines based on the
// longest word.
/* istanbul ignore next */
line += pad(arr[i], longest, ' ');
}
}
Expand Down
1 change: 1 addition & 0 deletions test/alias.js
Expand Up @@ -20,6 +20,7 @@ function clear() {

describe('alias', function () {
before(function () {
process.stdout.columns = 1000;
clear();
});

Expand Down
1 change: 1 addition & 0 deletions test/cat.js
Expand Up @@ -7,6 +7,7 @@ const $ = require('shelljs');

describe('cat', function () {
before(function () {
process.stdout.columns = 1000;
new $.ShellString('aardvark').to('a.test');
new $.ShellString('batman').to('b.test');
new $.ShellString('dont\n\n\neat\naardvarks\n\n\n').to('c.test2');
Expand Down
1 change: 1 addition & 0 deletions test/cd.js
Expand Up @@ -9,6 +9,7 @@ const delimiter = require('../dist/delimiter');

describe('cd', function () {
before(function (done) {
process.stdout.columns = 1000;
util.writeSampleDir(function () {
process.chdir('./testing/');
done();
Expand Down
1 change: 1 addition & 0 deletions test/cp.js
Expand Up @@ -29,6 +29,7 @@ function reset() {

describe('cp', function () {
before(function () {
process.stdout.columns = 1000;
burninate();
});

Expand Down
1 change: 1 addition & 0 deletions test/echo.js
Expand Up @@ -6,6 +6,7 @@ const cash = require('../dist/index.js');

describe('echo', function () {
before(function (done) {
process.stdout.columns = 1000;
done();
});

Expand Down
1 change: 1 addition & 0 deletions test/export.js
Expand Up @@ -8,6 +8,7 @@ let oldProcessEnv;

describe('export', function () {
before(function () {
process.stdout.columns = 1000;
oldProcessEnv = process.env;
});

Expand Down
1 change: 1 addition & 0 deletions test/head.js
Expand Up @@ -16,6 +16,7 @@ const fxt = {

describe('head', function () {
before(function () {
process.stdout.columns = 1000;
new $.ShellString('line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10\nline11').to('eleven.test');
new $.ShellString('line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10').to('ten.test');
});
Expand Down
2 changes: 2 additions & 0 deletions test/index.js
Expand Up @@ -16,6 +16,7 @@ describe('cash', function () {

describe('.cashrc', function () {
before(function () {
process.stdout.columns = 1000;
cashrcPath = `${delimiter.getHomeDir()}/.cashrc`;
cashrcCopy = `${cashrcPath}_${String(Math.random())}`;
if ($.test('-f', cashrcPath)) {
Expand Down Expand Up @@ -49,6 +50,7 @@ describe('cash', function () {

describe('template literals', function () {
before(function () {
process.stdout.columns = 1000;
cash = require('..');
$.rm('-rf', 'test-template');
});
Expand Down
1 change: 1 addition & 0 deletions test/ls.js
Expand Up @@ -37,6 +37,7 @@ function ls(path, opts) {
if (os.platform() !== 'win32') {
describe('ls', function () {
before(function (done) {
process.stdout.columns = 1000;
$.mkdir('-p', './atatatest/foo/bar');
$.touch('./atatatest/foo/bar/cows.file');
util.writeSampleDir(function () {
Expand Down
1 change: 1 addition & 0 deletions test/mkdir.js
Expand Up @@ -7,6 +7,7 @@ const $ = require('shelljs');

describe('mkdir', function () {
before(function () {
process.stdout.columns = 1000;
$.rm('-rf', './testabot*');
});

Expand Down
1 change: 1 addition & 0 deletions test/mv.js
Expand Up @@ -24,6 +24,7 @@ function reset() {

describe('mv', function () {
before(function () {
process.stdout.columns = 1000;
burninate();
});

Expand Down
2 changes: 2 additions & 0 deletions test/preparser.js
Expand Up @@ -31,6 +31,7 @@ describe('preparser', function () {

describe('environmental variables', function () {
before(function () {
process.stdout.columns = 1000;
process.env.FOO = 'This*string\'has $pecial${characters}';
});
it('should convert simple variable references', function () {
Expand Down Expand Up @@ -97,6 +98,7 @@ describe('preparser', function () {
});
describe('commands are preparsed', function () {
before(function () {
process.stdout.columns = 1000;
process.env.FOO = 'thisfiledoesntexist';
});

Expand Down
1 change: 1 addition & 0 deletions test/rm.js
Expand Up @@ -8,6 +8,7 @@ const $ = require('shelljs');

describe('rm', function () {
before(function () {
process.stdout.columns = 1000;
$.mkdir('rm-test');
$.mkdir('./rm-test/sub');
new $.ShellString('1').to('1.rm');
Expand Down
1 change: 1 addition & 0 deletions test/sort.js
Expand Up @@ -18,6 +18,7 @@ function sort(dir, opts) {

describe('sort', function () {
before(function (done) {
process.stdout.columns = 1000;
setTimeout(function () {
new $.ShellString('zaz\nsss\nqqq\n-zbz\nBBB\nddd\nCCC\n2bbb\nccc\n').to('./default.sort');
new $.ShellString('22 zaz\n33 sss\n11 qqq\n77 ccc\n55 BBB\nddd\nCCC\n2bbb\n-zbz\n').to('./numeric.sort');
Expand Down
1 change: 1 addition & 0 deletions test/source.js
Expand Up @@ -13,6 +13,7 @@ const usage = `-cash: source: filename argument required\nsource: usage: source

describe('source', function () {
before(function () {
process.stdout.columns = 1000;
oldCwd = process.cwd();
oldProcessEnv = process.env;
new $.ShellString('echo " hello world"\nalias foo bar\n').to('a.sh');
Expand Down
1 change: 1 addition & 0 deletions test/tail.js
Expand Up @@ -15,6 +15,7 @@ const fxt = {

describe('tail', function () {
before(function () {
process.stdout.columns = 1000;
new $.ShellString('line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10\nline11\n').to('eleven.test');
new $.ShellString('line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10\n').to('ten.test');
});
Expand Down
1 change: 1 addition & 0 deletions test/touch.js
Expand Up @@ -8,6 +8,7 @@ const fs = require('fs-extra');

describe('touch', function () {
before(function (done) {
process.stdout.columns = 1000;
util.writeSampleDir(function () {
process.chdir('./testing/');
done();
Expand Down
1 change: 1 addition & 0 deletions test/unalias.js
Expand Up @@ -20,6 +20,7 @@ function clear() {

describe('alias', function () {
before(function () {
process.stdout.columns = 1000;
clear();
});

Expand Down

0 comments on commit 1f42d3b

Please sign in to comment.