Skip to content

Instantly share code, notes, and snippets.

@jjanssen
Forked from anonymous/index.html
Created June 1, 2016 18:06
Show Gist options
  • Save jjanssen/5765cd9110dbb864121991ace5dbb63c to your computer and use it in GitHub Desktop.
Save jjanssen/5765cd9110dbb864121991ace5dbb63c 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