1 | 'use strict';
|
2 |
|
3 | var deepEqual = require('deep-equal');
|
4 | var template = require('../lib/template');
|
5 |
|
6 | exports.status = function(status) {
|
7 | return function(req, res) {
|
8 | if (res && res.statusCode != status) {
|
9 | return new Error(
|
10 | 'response status code was ' + res.statusCode +
|
11 | '. Expected ' + status);
|
12 | } else {
|
13 | return true;
|
14 | }
|
15 | };
|
16 | };
|
17 |
|
18 | exports.body = function(body) {
|
19 | var tpl = template.prepare(body);
|
20 | return function(req, res) {
|
21 | var body = template.render(tpl, {req: req, res: res});
|
22 | if (res && res.body != body && !deepEqual(res.body, body)) {
|
23 | return new Error(
|
24 | 'response body was ' + JSON.stringify(res.body) +
|
25 | '. Expected ' + JSON.stringify(body));
|
26 | } else {
|
27 | return true;
|
28 | }
|
29 | }
|
30 | }; |
\ | No newline at end of file |