我在emberjs网站上关注the tutorial。我已经完成所有工作,但测试失败了404。
蜃/ 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'
});
列表出租-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');
});
});
结果是
Not found: /api/rentals
should redirect automatically
Expected:
"/rentals"
Result:
"/"
该应用程序运行良好,但我也希望测试通过。有什么建议吗?