huntsman
Version:
Super configurable async web spider
28 lines (25 loc) • 618 B
JavaScript
// @todo, body moved inside res.
// @todo needs tests.
var examples = {
'http://www.example.com': {
err: null,
res: {
uri: 'http://www.example.com',
statusCode: 200,
headers: [ 'Content-Type: text/html' ],
body: '<html><body>Hello World!</body></html>'
}
}
};
module.exports = function( fixtures ){
if( !fixtures ) fixtures = examples;
return function( uri, cb ){
if( uri in fixtures ) return cb( fixtures[ uri ].err, fixtures[ uri ].res );
return cb( 'fixture not found', {
uri: uri,
statusCode: 404,
headers: [],
body: ''
});
};
};