我在我的控制器中有服务,
$scope.doLogin=function(email, password) {
$http.post("oauth/token", "grant_type=password&username=test@test.com&password=123456", {
headers: {
'Authorization': "BASIC",
'Content-Type': "application/json"
}
}).success(function(data, status) {
}).error(function(data) {
console.log(data);
})
}
这是我的测试用例
describe ('when populate method is called', function () {
it ('should returns user data', function () {
var p = $scope.doLogin('associate11@test.com', '123456');
$httpBackend.whenPOST("/oauth/token");
$httpBackend.flush();
p.then(function(response) {
expect(response.data).toBeDefined();
});
});
});
我得到的错误是:
错误:意外请求:POST https://test/oauth/token 不再需要预期