Skip to content

Commit 179a610

Browse files
committed
Update to README
1 parent f04ac1e commit 179a610

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

README.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,48 @@ the testing of API routes to check that the responses match those expected creat
1919

2020
In order to use ``abe-express`` you will use this within your current testing setup
2121

22+
### Header test
23+
24+
This is a helper which will run a test against your API ensuring that the response matches that of your mock. In order to do this, it will match the ``status`` code of your mock, it will also test the expected ``Content-type`` matches (this is only done if your mock contains the ``Content-type`` in it's headers).
25+
2226
```js
23-
var abeExpress = require('abe-express');
24-
abeExpress.full(app, mock, example, done);
27+
var abeExpress = require('abe-express'),
28+
myApp = require('../app.js'),
29+
mock = require('../mocks/example.json'),
30+
example = 'OK';
31+
32+
it('Should return a 200 status code', function (done) {
33+
abeExpress.header(myApp, mock, example, done);
34+
});
2535
```
36+
### Full test
2637

27-
```abeExpress``` also provides a header test for you to just test the response headers
38+
This is a helper which will run all tests against your API, ensuring that the body response of your API matches that of your mock. It will also run the tests against the ``header``.
2839

2940
```js
30-
abeExpress.header(app, mock, example, done);
41+
var abeExpress = require('abe-express'),
42+
myApp = require('../app.js'),
43+
mock = require('../mocks/example.json'),
44+
example = 'OK';
45+
46+
it('Should return a 200 status code and body', function (done) {
47+
abeExpress.full(myApp, mock, example, done);
48+
});
3149
```
50+
### Params
3251

33-
### App
52+
#### App
3453

3554
This will be your Express app in which the route has been attached to in which you want to test.
3655

37-
### Mock
56+
#### Mock
3857

3958
This will be the full ``ABE-Spec`` mock in which you are wanting to test against.
4059

41-
### Example
60+
#### Example
4261

4362
This is the ``key`` within the ``examples`` object of your mock.
4463

45-
### Done
64+
#### Done
4665

4766
This is the function which your testing system will pass within a ``it`` test, to tell your test that it has completed.
48-
49-
Example:
50-
51-
```js
52-
it('should pass', function (done) {
53-
abeExpress(app, mock, example, done);
54-
});
55-
```
56-
57-
It is expected that you pre-load your mock file previously to be able to pass it to the helper

0 commit comments

Comments
 (0)