Skip to content

Commit 8fc59b5

Browse files
committed
修正 ajax.js 在错误情况下返回值格式不正确的错误
1 parent 935f259 commit 8fc59b5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/browserify-wrapper/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = function _ajax(method, resourceUrl, data, success, error) {
5353
promise.reject(err);
5454
}
5555
} else {
56-
promise.reject(JSON.parse(responseText));
56+
promise.reject({responseText: responseText});
5757
}
5858
});
5959
});

test/user.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ describe("User", function() {
6868
});
6969

7070
});
71+
72+
it("should fail with wrong password", function() {
73+
return AV.User.logIn(username, 'wrong password').then(function() {
74+
throw new Error('Should not success');
75+
}, function(err) {
76+
expect(err.code).to.be.equal(210);
77+
expect(err.message).to.be.equal('The username and password mismatch.');
78+
});
79+
});
80+
7181
});
7282

7383

0 commit comments

Comments
 (0)