$httpBackend.whenGET('/restpath/api/v1/books')
.respond({// some data});
I get the following error
Error: Unexpected request: GET /restpath/api/v1/books
Expected GET /restpath/api/v1/books?limit=10&start=1
For the expectGET I have the following , and this creates dynamic query string. mostly the 'start' parameter, and the whenGET part, I am trying to server a dynamic content depending on the 'start'
$httpBackend.expectGET('/restpath/api/v1/books?limit=10&start=1');
// the actual service goes here , which does the $http service. we don't care
$httpBackend.flush();
(for angular apps with versions lower than v1.5.0-build.4371 )
If you dont care about the parameters after your '?' you can do this :
$httpBackend.expectGET(/.*?restpath\/api\/v1\/books?.*/g).respond(200, '{}');
if you care about the first param do this :
$httpBackend.expectGET(/.*?restpath\/api\/v1\/books?limit=10.*/g).respond(200, '{}');
if you care about them all do this :
$httpBackend.expectGET("/restpath/api/v1/books?limit=10&start=1").respond(200, '{}');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With