-
-
Save jjanssen/5765cd9110dbb864121991ace5dbb63c to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yanamaqodi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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