angularjs - protractor different mock httpbackend responses -


i'm using mock module testing.

when page gets loaded e.g.

    browser.get('http://localhost:5643/#/balance/import'); 

this api url below gets called , below response works fine.

$httpbackend.whenget('https://localhost:44329/api/daystatus').respond(                 {                     'dayid': 249,                     'weekend': false,                     'daystatustypeid': 5,                     'balance': null                 }             ); 

but when page gets loaded e.g.

    browser.get('http://localhost:5643/#/dashboard'); 

and calls api url in mock module

but time want return different response. (because previous page loaded , ui test actions took place.)

$httpbackend.whenget('https://localhost:44329/api/daystatus').respond(                 {                     'dayid': 249,                     'weekend': false,                     'daystatustypeid': 7,                     'balance': null                 }             ); 

how can in mock module use second call api url time not first? @ moment whatever page load uses:

$httpbackend.whenget('https://localhost:44329/api/daystatus').respond(                 {                     'dayid': 249,                     'weekend': false,                     'daystatustypeid': 5,                     'balance': null                 }             ); 

can detect page request came from..or can pass in querystring variables? not sure how go this.

you can distinguish api calls referer header:

$httpbackend.whenget('https://localhost:44329/api/daystatus',                       {'referer': 'http://localhost:5643/#/balance/import'}) 

and:

$httpbackend.whenget('https://localhost:44329/api/daystatus',                       {'referer': 'http://localhost:5643/#/dashboard'}) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -