Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: rename some tests
No change to logic.

This renames some tests to be a bit more readable.
  • Loading branch information
nfischer committed Jul 6, 2018
commit e6b631f73a911ce72573bc4cbc196f25a07b0614
53 changes: 22 additions & 31 deletions test/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('invalid option', t => {
t.is(result.stderr, 'cp: option not recognized: @');
});

test('invalid option', t => {
test('invalid option #2', t => {
const result = shell.cp('-Z', 'asdfasdf', `${t.context.tmp}/file2`);
t.truthy(shell.error());
t.is(result.code, 1);
Expand Down Expand Up @@ -265,9 +265,8 @@ test('recursive, nothing exists', t => {
t.is(shell.ls('-R', 'test/resources/cp').toString(), shell.ls('-R', `${t.context.tmp}/cp`).toString());
});

test(
'recursive, nothing exists, source ends in \'/\' (see Github issue #15)',
t => {
test('recursive, nothing exists, source ends in "/"', t => {
// Github issue #15
const result = shell.cp('-R', 'test/resources/cp/', `${t.context.tmp}/`);
t.falsy(shell.error());
t.falsy(result.stderr);
Expand All @@ -276,9 +275,8 @@ test(
}
);

test(
'recursive, globbing regular files with extension (see Github issue #376)',
t => {
test('recursive, globbing regular files with extension', t => {
// Github issue #376
const result = shell.cp('-R', 'test/resources/file*.txt', t.context.tmp);
t.falsy(shell.error());
t.falsy(result.stderr);
Expand All @@ -288,9 +286,8 @@ test(
}
);

test(
'recursive, copying one regular file (also related to Github issue #376)',
t => {
test('recursive, copying one regular file', t => {
// Github issue #376
const result = shell.cp('-R', 'test/resources/file1.txt', t.context.tmp);
t.falsy(shell.error());
t.falsy(result.stderr);
Expand Down Expand Up @@ -365,9 +362,8 @@ test('recursive, everything exists, with force flag', t => {
t.is(shell.cat('test/resources/cp/dir_a/z').toString(), shell.cat(`${t.context.tmp}/cp/dir_a/z`).toString()); // after cp
});

test(
'recursive, creates dest dir since it\'s only one level deep (see Github issue #44)',
t => {
test("recursive, creates dest dir since it's only one level deep", t => {
// Github issue #44
const result = shell.cp('-r', 'test/resources/issue44', `${t.context.tmp}/dir2`);
t.falsy(shell.error());
t.falsy(result.stderr);
Expand All @@ -380,9 +376,8 @@ test(
}
);

test(
'recursive, does *not* create dest dir since it\'s too deep (see Github issue #44)',
t => {
test("recursive, does *not* create dest dir since it's too deep", t => {
// Github issue #44
const result = shell.cp('-r', 'test/resources/issue44', `${t.context.tmp}/dir2/dir3`);
t.truthy(shell.error());
t.is(
Expand All @@ -409,21 +404,17 @@ test('recursive, with trailing slash, does the exact same', t => {
t.truthy(fs.existsSync(`${t.context.tmp}/dest/z`));
});

test(
'On Windows, permission bits are quite different so skip those tests for now',
t => {
utils.skipOnWin(t, () => {
// preserve mode bits
const execBit = parseInt('001', 8);
t.is(common.statFollowLinks('test/resources/cp-mode-bits/executable').mode & execBit, execBit);
shell.cp('test/resources/cp-mode-bits/executable', `${t.context.tmp}/executable`);
t.is(
common.statFollowLinks('test/resources/cp-mode-bits/executable').mode,
common.statFollowLinks(`${t.context.tmp}/executable`).mode
);
});
}
);
test('preserve mode bits by default for file', t => {
utils.skipOnWin(t, () => {
const execBit = parseInt('001', 8);
t.is(common.statFollowLinks('test/resources/cp-mode-bits/executable').mode & execBit, execBit);
shell.cp('test/resources/cp-mode-bits/executable', `${t.context.tmp}/executable`);
t.is(
common.statFollowLinks('test/resources/cp-mode-bits/executable').mode,
common.statFollowLinks(`${t.context.tmp}/executable`).mode
);
});
});

test('Make sure hidden files are copied recursively', t => {
shell.rm('-rf', t.context.tmp);
Expand Down
6 changes: 3 additions & 3 deletions test/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('simple test with defaults', t => {
});

test('allow arguments to begin with a hyphen', t => {
// see issue #20
// Github issue #20
const result = shell.echo('-asdf', '111');
const stdout = mocks.stdout();
const stderr = mocks.stderr();
Expand Down Expand Up @@ -62,7 +62,7 @@ test('-e option', t => {
});

test('piping to a file', t => {
// see issue #476
// Github issue #476
shell.mkdir(t.context.tmp);
const tmp = `${t.context.tmp}/echo.txt`;
const resultA = shell.echo('A').toEnd(tmp);
Expand Down Expand Up @@ -121,7 +121,7 @@ test('-en option with escaped characters', t => {
});

test('piping to a file with -n', t => {
// see issue #476
// Github issue #476
shell.mkdir(t.context.tmp);
const tmp = `${t.context.tmp}/echo.txt`;
const resultA = shell.echo('-n', 'A').toEnd(tmp);
Expand Down