mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
No change to logic. This swaps over tests to use require() since everything is currently designed for the commonjs module system.
42 lines
797 B
JavaScript
42 lines
797 B
JavaScript
const path = require('path');
|
|
|
|
const test = require('ava');
|
|
|
|
const shell = require('..');
|
|
const utils = require('./utils/utils');
|
|
|
|
const cur = process.cwd();
|
|
|
|
test.beforeEach(t => {
|
|
t.context.tmp = utils.getTempDir();
|
|
shell.config.resetForTesting();
|
|
shell.mkdir(t.context.tmp);
|
|
});
|
|
|
|
test.afterEach.always(t => {
|
|
process.chdir(cur);
|
|
shell.rm('-rf', t.context.tmp);
|
|
});
|
|
|
|
|
|
//
|
|
// Valids
|
|
//
|
|
|
|
test('initial directory', t => {
|
|
const cwd = shell.pwd();
|
|
t.falsy(shell.error());
|
|
t.is(cwd.code, 0);
|
|
t.falsy(cwd.stderr);
|
|
t.is(cwd.toString(), path.resolve('.'));
|
|
});
|
|
|
|
test('after changing directory', t => {
|
|
shell.cd(t.context.tmp);
|
|
const cwd = shell.pwd();
|
|
t.is(cwd.code, 0);
|
|
t.falsy(cwd.stderr);
|
|
t.falsy(shell.error());
|
|
t.is(path.basename(cwd.toString()), t.context.tmp);
|
|
});
|