filer/tests/spec/shell/exec.spec.js

34 lines
956 B
JavaScript
Raw Normal View History

2014-02-15 20:28:00 +00:00
define(["Filer", "util"], function(Filer, util) {
describe('FileSystemShell.exec', function() {
beforeEach(util.setup);
afterEach(util.cleanup);
it('should be a function', function() {
var shell = util.shell();
expect(shell.exec).to.be.a('function');
});
it('should be able to execute a command .js file from the filesystem', function(done) {
var fs = util.fs();
var shell = fs.Shell();
var cmdString = "fs.writeFile(options.path, options.data, callback);";
fs.writeFile('/cmd.js', cmdString, function(error) {
if(error) throw error;
shell.exec('/cmd.js', {path: '/test', data: 'hello world'}, function(error, result) {
if(error) throw error;
fs.readFile('/test', 'utf8', function(error, data) {
if(error) throw error;
expect(data).to.equal('hello world');
done();
});
});
});
});
});
});