Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, function run(err, res, body) {
t.error(err, 'No error while calling /1/indexes/JSONP-syntax-error/reset');
t.deepEqual(body, {calls: 0}, 'No JSONP calls done');
fauxJax.install();
index.search('JSONP Failure', searchCallback);
fauxJax.on('request', function(req) {
// we should pass here as much time as the number of hosts (2)
t.pass();
// simulate network error
req.onerror();
});
});
}, function run(err) {
t.error(err, 'No error while reseting the /1/indexes/request-strategy-uses-JSONP route');
fauxJax.install();
index.search('hello', searchCallback);
fauxJax.on('request', function(req) {
nbRequests++;
req.respond(500, {}, JSON.stringify({message: 'Try again', status: 500}));
});
});
});
}, function run(err) {
t.error(err, 'No error while reseting the /1/indexes/slow-response route');
fauxJax.install();
fauxJax.on('request', function(req) {
req.respond(500, {}, JSON.stringify({status: 500, message: 'woops!'}));
});
index.search('hello', searchCallback);
});
});
index.search('jquery-timeout-promise').then(function searchDone(content) {
fauxJax.restore();
t.deepEqual(
content, {
yaw: 'JQUERY! timeout'
},
'Content matches'
);
});
index.search('angular-first').then(function searchDone(content) {
fauxJax.restore();
t.deepEqual(
content, {
message: 'YEAH!'
},
'Content matches'
);
});