I'm following the tutorial on the emberjs website. I have it all working but the tests are failing with 404s.
mirage/config.js
export default function() {
this.namespace = '/api';
this.get('/rentals', function(db, request){
if(request.queryParams.city !== undefined) {
let filteredRentals = rentals.filter(function(i){
return i.attributes.city.toLowerCase().indexOf(request.queryParams.city.toLowerCase()) !== -1;
});
return { data: filteredRentals };
} else {
return { data: rentals };
}
});
}
application.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
namespace: 'api'
});
list-rentals-test.js
import { test } from 'qunit';
import moduleForAcceptance from 'super-rentals/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | list rentals');
test('should redirect to rentals route.', function(assert) {
visit('/');
andThen(function(){
assert.equal(currentURL(), '/rentals', 'should redirect automatically');
});
});
the result is
Not found: /api/rentals
should redirect automatically
Expected:
"/rentals"
Result:
"/"
The app works perfectly but I would like to get the tests to pass as well. Any suggestions?
Aucun commentaire:
Enregistrer un commentaire