Merge pull request #710 from sdf611097/typeChecking

Add __type checking
This commit is contained in:
Drew
2016-03-02 14:57:19 -08:00
3 changed files with 70 additions and 17 deletions

View File

@@ -336,6 +336,34 @@ describe('Parse.Object testing', () => {
item.save({ "foo^bar": "baz" }).then(fail, done);
});
it("invalid __type", function(done) {
var item = new Parse.Object("Item");
var types = ['Pointer', 'File', 'Date', 'GeoPoint', 'Bytes'];
var Error = Parse.Error;
var tests = types.map(type => {
var test = new Parse.Object("Item");
test.set('foo', {
__type: type
});
return test;
});
var next = function(index) {
if (index < tests.length) {
tests[index].save().then(fail, error => {
expect(error.code).toEqual(Parse.Error.INCORRECT_TYPE);
next(index + 1);
});
} else {
done();
}
}
item.save({
"foo": {
__type: "IvalidName"
}
}).then(fail, err => next(0));
});
it("simple field deletion", function(done) {
var simple = new Parse.Object("SimpleObject");
simple.save({