Skip to content

Commit 5e0a7f3

Browse files
committed
Merge pull request #225 from jysperm/master
修正 ajax.js 在错误情况下返回值格式不正确的错误
2 parents 935f259 + b51f3af commit 5e0a7f3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

gulpfile.babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ gulp.task('compress-docs', ['docs'], () => {
147147
});
148148

149149
// Istanbul unit test coverage plugin for gulp.
150-
gulp.task('instrument', () => {
150+
gulp.task('instrument', ['release'], () => {
151151
return gulp.src(['dist/node/**/*.js'])
152152
.pipe(istanbul())
153153
.pipe(istanbul.hookRequire());

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)