Skip to content

Commit

Permalink
Also use prettier for markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Mar 29, 2020
1 parent 071c835 commit 72968a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
httpception
===========
# httpception

[![NPM version](https://badge.fury.io/js/httpception.svg)](http://badge.fury.io/js/httpception)
[![Build Status](https://travis-ci.org/papandreou/httpception.svg?branch=master)](https://travis-ci.org/papandreou/httpception)
Expand All @@ -15,20 +14,19 @@ var got = require('got');
var assert = require('assert');

it('should perform the right HTTP request', () => {
httpception({
request: 'GET http://example.com/foobar',
response: {
headers: {
'Content-Type': 'text/plain'
},
body: 'the text'
}
});

return got('example.com/foobar')
.then(response => {
assert.equal(response.body, 'the text');
});
httpception({
request: 'GET http://example.com/foobar',
response: {
headers: {
'Content-Type': 'text/plain',
},
body: 'the text',
},
});

return got('example.com/foobar').then((response) => {
assert.equal(response.body, 'the text');
});
});
```

Expand All @@ -43,18 +41,21 @@ function returns a promise, the mocks will be kept until the promise has
resolved:

```js
it('should perform the right HTTP request', () => httpception({
request: 'GET /foobar',
response: {
it('should perform the right HTTP request', () =>
httpception(
{
request: 'GET /foobar',
response: {
statusCode: 200,
body: 'the text'
body: 'the text',
},
},
() => {
return got('example.com/foobar').then((response) => {
assert.equal(response.body, 'the text');
});
}
}, () => {
return got('example.com/foobar')
.then(response => {
assert.equal(response.body, 'the text');
});
}));
));
```

When the test is done, the http module will automatically be restored,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Mock HTTP module",
"main": "lib/httpception.js",
"scripts": {
"lint": "eslint . && prettier --check '**/*.js'",
"lint": "eslint . && prettier --check '**/*.{js,md}'",
"test": "npm run test-mocha && npm run test-jest && npm run test-integration",
"test-integration": "mocha integration-test/test.js --timeout 30000",
"test-mocha": "mocha --opts test/mocha/mocha.opts",
Expand Down

0 comments on commit 72968a9

Please sign in to comment.