next

If there are multiple matching routes, only the most recently-added will be called. Calling next allows you to trigger the next route.

http.when('api/1').return('foo');
http.when('api/2').return('bah');
http.when(/api\/d+/).call(spy).next();

var response1 = await http.get('api/1'); // 'foo'
var response2 = await http.get('api/2');  // 'bah'
var response3 = await http.get('api/3'); // undefined
// spy will have been called 3 times

You can also trigger the next route manually within a callback method:

http.when(/api\/d+/).call(config => {
  // do some stuff
  return config.next();
});

And you can also trigger the previous route before the current route is finished:

http.when(/api\/d+/).call(spy1).next().return('abc');

results matching ""

    No results matching ""