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

34 lines
952 B
JavaScript
Raw Normal View History

2014-05-23 20:53:50 +00:00
var Filer = require('../../..');
var util = require('../../lib/test-utils.js');
var expect = require('chai').expect;
2014-02-15 20:28:00 +00:00
2014-05-23 20:53:50 +00:00
describe('FileSystemShell.exec', function() {
beforeEach(util.setup);
afterEach(util.cleanup);
2014-02-15 20:28:00 +00:00
2014-05-23 20:53:50 +00:00
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();
2014-10-24 18:19:17 +00:00
var shell = new fs.Shell();
2014-05-23 20:53:50 +00:00
var cmdString = "fs.writeFile(args[0], args[1], callback);";
2014-02-15 20:28:00 +00:00
2014-05-23 20:53:50 +00:00
fs.writeFile('/cmd.js', cmdString, function(error) {
if(error) throw error;
2014-02-15 20:28:00 +00:00
2014-05-23 20:53:50 +00:00
shell.exec('/cmd.js', ['/test', 'hello world'], function(error, result) {
2014-02-15 20:28:00 +00:00
if(error) throw error;
2014-05-23 20:53:50 +00:00
fs.readFile('/test', 'utf8', function(error, data) {
2014-02-15 20:28:00 +00:00
if(error) throw error;
2014-05-23 20:53:50 +00:00
expect(data).to.equal('hello world');
done();
2014-02-15 20:28:00 +00:00
});
});
});
});
});