Skip to content

Instantly share code, notes, and snippets.

Created June 1, 2016 18:05
Show Gist options
  • Save anonymous/6ea481b98ca702285ac591cb9220841e to your computer and use it in GitHub Desktop.
Save anonymous/6ea481b98ca702285ac591cb9220841e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yanamaqodi
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.0.8/es5-shim.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sinon.js/1.15.4/sinon.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.12.0/axios.min.js"></script>
</head>
<body>
<script id="jsbin-javascript">
'use strict';
function wrap() {
return getExample();
}
function getExample() {
return axios.get('https://api.github.com/');
}
var sandbox = sinon.sandbox.create();
var data = ['john', 'doe', 'pogi'];
var resolved = new Promise(function (r) {
return r(data);
});
var callback = sandbox.stub(axios, 'get').returns(resolved);
//var spy = sinon.spy(axios, 'get');
wrap();
console.log(callback());
sandbox.restore();
</script>
<script id="jsbin-source-javascript" type="text/javascript">function wrap() {
return getExample();
}
function getExample() {
return axios.get('https://api.github.com/');
}
var sandbox = sinon.sandbox.create();
var data = ['john', 'doe', 'pogi'];
var resolved = new Promise(function(r) {
return r(data);
});
var callback = sandbox.stub(axios, 'get').returns(resolved);
//var spy = sinon.spy(axios, 'get');
wrap();
console.log(callback());
sandbox.restore();</script></body>
</html>
'use strict';
function wrap() {
return getExample();
}
function getExample() {
return axios.get('https://api.github.com/');
}
var sandbox = sinon.sandbox.create();
var data = ['john', 'doe', 'pogi'];
var resolved = new Promise(function (r) {
return r(data);
});
var callback = sandbox.stub(axios, 'get').returns(resolved);
//var spy = sinon.spy(axios, 'get');
wrap();
console.log(callback());
sandbox.restore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment