Hi,
We have a test case where we want to have sinon use query parameters as arguments for modifying the response body. Specifically, we pass result range (startIndex,endIndex) as query params, and want to return that specific slice of a result array. It seems like the respondWith only allows fixed objects as response and not functions.
Ideally, the code would look like this:
var iterativeResponse = function(){
var body = {
'resources' : mockUsers.slice(startIndex, startIndex+2),
'startIndex' : startIndex,
'totalResults' : mockUsers.length
};
console.log(startIndex);
startIndex += 2;
return JSON.stringify(body);
};
server.respondWith('GET', /\/users\?.*/, [200, responseHeaders.json, iterativeResponse]);
Is there a way around this problem?
Thanks,
Audrey