它看起来很简单,但无论我使用$httpBackend
与否,它永远不会返回!
describe('R', function(){
var Res, http, item, original = {name:"John"};
beforeEach(function () {
module('app');
inject(function ($httpBackend, $resource) {
http = $httpBackend;
Res = $resource('/api/user/:user', {user:'@id'});
});
});
beforeEach(function (done) {
http.when('GET','/api/user/1').respond(original);
console.log("I GET CALLED");
Res.get({id:'1'},function (res) {
console.log("I NEVER GET CALLED");
item = res;
done();
});
});
it('should just be true', function(){
expect(true).toBe(true);
});
});
为什么第二console.log
行永远不会被调用?