34 lines
956 B
JavaScript
34 lines
956 B
JavaScript
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();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|