Skip to content

Instantly share code, notes, and snippets.

@sebv
Last active January 31, 2018 09:01
Show Gist options
  • Save sebv/50c3481ab33ebd9b93cb to your computer and use it in GitHub Desktop.
Save sebv/50c3481ab33ebd9b93cb to your computer and use it in GitHub Desktop.
var sinon = require('sinon'),
support = require('appium-support'),
Q = require('q'),
chai = require("chai");
should = chai.should();
function actualLogic(cmd) {
return support.core.exec("sleep 10000 && " + cmd).then(function(res) {
return res[0].toUpperCase();
});
}
describe('example', function() {
it("should work", function() {
var mock = sinon.mock(support.core);
mock.expects("exec").once().withArgs('sleep 10000 && echo "hello world"').returns(new Q(['hello world', null]));
return actualLogic('echo "hello world"').then(function(res){
res.should.equal('HELLO WORLD');
}).finally(function(){
mock.verify();
mock.restore();
});
});
});
@Jonahss
Copy link

Jonahss commented May 1, 2015

(It also looks like @mentions don't work in gists?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment