Last active
November 17, 2016 09:03
-
-
Save joelmukuthu/cb1b8fa76cfe2f90a4add0b14b7be7d3 to your computer and use it in GitHub Desktop.
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
var httpception = require('httpception'); | |
var got = require('got'); | |
var assert = require('assert'); | |
describe('the thing', function () { | |
before(function() { | |
httpception({ | |
request: 'GET http://example.com/foobar', | |
response: { | |
headers: { | |
'Content-Type': 'text/plain' | |
}, | |
body: 'the text' | |
} | |
}); | |
}); | |
it('GETs it', function () { | |
return got('example.com/foobar') | |
.then(response => assert.equal(response.body, 'the text')); | |
}); | |
describe('POSTs it', function () { | |
before(function () { | |
httpception({ | |
request: 'POST http://example.com/foobar', | |
response: 201 | |
}); | |
}); | |
it('right', function () { | |
return got.post('example.com/foobar') | |
.then(response => assert.equal(response.statusCode, 201)); | |
}); | |
it('but still GETs it', function () { | |
return got('example.com/foobar') | |
.then(response => assert.equal(response.body, 'the text')); | |
}); | |
it('and can also PUT it', function () { | |
httpception({ | |
request: 'PUT http://example.com/foobar', | |
response: 202 | |
}); | |
return got.put('example.com/foobar') | |
.then(response => assert.equal(response.statusCode, 202)); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment