Skip to content

Instantly share code, notes, and snippets.

@haru01
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haru01/2b3ef0ce351ed1e9dad6 to your computer and use it in GitHub Desktop.
Save haru01/2b3ef0ce351ed1e9dad6 to your computer and use it in GitHub Desktop.
'use strict';
var fetch = require('node-fetch');
var assert = require('power-assert');
function fetchPost() {
return fetch("http://jsonplaceholder.typicode.com/posts/1")
.then(function(res) {
return res.json();
}).catch(function(e) {
throw e;
});
}
describe('fetch & promise & power-assert', function () {
it("should fetch post", function (done) {
fetchPost()
.then(function(post) {
assert(post.id === 2) // fail
done();
}).catch(done);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment