ember.js - pretender and query params -
i'm using pretender lib trek success long don't have query params.
i've spent officialiy 4 hours staring @ code below , can't work. i'm defining url doesn't seem hit. when @ call has not been caught coming exact url defined! if can me out 1 great.
the test code have:
var server; module("check search index page", { setup: function() { 'use strict'; ember.run(function() { app.reset(); server = new pretender(function() { this.get('/api/v1/holidays.json?display_type=detail&page=1&sort%5bprice%5d=&sort%5bname%5d=&sort%5brating%5d=&filter%5bduration_min%5d=1&filter%5bduration_max%5d=32&filter%5bprice_min%5d=50&filter%5bprice_max%5d=3800&filter%5bbus%5d=true&filter%5bflight%5d=true&filter%5bself_transportation%5d=true', function (request) { return [200, {'content-type': 'application/json'}, '{"holidays":[{"id":507,"name":"app. elena"}']; }); }); server.unhandledrequest = function(verb, path, request) { console.log("=== begin unhandled request ==="); console.log('verb: ' + verb); console.log('path: ' + path); console.log('request: ' + request); console.log("=== end unhandled request ==="); }; }); }, teardown: function() { 'use strict'; server.shutdown(); } }); test('search page', function() { 'use strict'; visit('/search/index'); andthen(function() { ok(find('p:contains("bepaal uw zoek criteria")').length, 'search page showing'); }); });
and error message in console:
.=== begin unhandled request === verb: path: /api/v1/holidays.json?display_type=detail&page=1&sort%5bprice%5d=&sort%5bname%5d=&sort%5brating%5d=&filter%5bduration_min%5d=1&filter%5bduration_max%5d=32&filter%5bprice_min%5d=50&filter%5bprice_max%5d=3800&filter%5bbus%5d=true&filter%5bflight%5d=true&filter%5bself_transportation%5d=true request: [object object] === end unhandled request ===
you should't define query params in request definition. code above work definition of end point should be:
server = new pretender(function() { this.get('/api/v1/holidays.json?', function (request) { return [200, {'content-type': 'application/json'}, '{"holidays":[{"id":507,"name":"app. elena"}']; }); });
Comments
Post a Comment