0

我正在学习 emberjs 网站上的教程。我一切正常,但测试失败了 404s。

海市蜃楼/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 };
    }
  });
}

应用程序.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:     
  "/"

该应用程序运行良好,但我也想让测试通过。有什么建议么?

4

0 回答 0