Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis committed Dec 9, 2020
1 parent 60bbd42 commit 56462c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('Cloud Code', () => {
obj.set('foo', 'bar');
try {
await obj.save();
expect(false).toBe(true);
fail('should not succeed');
} catch (e) {
expect(e.message).toBe('Invalid field name: length.');
}
Expand Down
22 changes: 13 additions & 9 deletions spec/ParseObject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,15 +728,19 @@ describe('Parse.Object testing', () => {
});
});

it('cannot save object with className field', async () => {
const obj = new TestObject();
obj.set('className', 'bar');
try {
await obj.save();
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Invalid field name: className.');
}
it('cannot save object with invalid field', async () => {
const invalidFields = ['className', 'length'];
const promises = invalidFields.map(async field => {
const obj = new TestObject();
obj.set(field, 'bar');
try {
await obj.save();
fail('should not succeed');
} catch (e) {
expect(e.message).toBe(`Invalid field name: ${field}.`);
}
});
await Promise.all(promises);
});

it('old attribute unset then unset', function (done) {
Expand Down
13 changes: 0 additions & 13 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2860,19 +2860,6 @@ describe('Parse.Query testing', () => {
});
});

it('object with length', async () => {
const TestObject = Parse.Object.extend('TestObject');
const obj = new TestObject();
obj.set('length', 5);
equal(obj.get('length'), 5);
try {
await obj.save();
expect(false).toBe(true);
} catch (e) {
expect(e.message).toBe('Invalid field name: length.');
}
});

it('include user', function (done) {
Parse.User.signUp('bob', 'password', { age: 21 }).then(function (user) {
const TestObject = Parse.Object.extend('TestObject');
Expand Down

0 comments on commit 56462c8

Please sign in to comment.