/** * Loads the NLP manager from an excel. * @param {String} filename Name of the file. */ async loadExcel(filename) { this.nlpManager.loadExcel(filename); await this.train(); this.save(); }
submit() { if (this.store && this.autosave === true) { this.save(); } return super.submit(); }
/** * Updates the epic score and saves the profile. */ updateEpicScore() { if (this.currentEpicScore > this.epicScore) { this.epicScore = this.currentEpicScore; this.averageGrade = this.calculateAverageGrade(); } this.save(); }
it('beforeSaveFile should throw error', async () => { await reconfigureServer({ filesAdapter: mockAdapter }); Parse.Cloud.beforeSaveFile(() => { throw new Parse.Error(400, 'some-error-message'); }); const file = new Parse.File('popeye.txt', [1, 2, 3], 'text/plain'); try { await file.save({ useMasterKey: true }); } catch (error) { expect(error.message).toBe('some-error-message'); } });
it('polygon three different points minimum', done => { const coords = [[0, 0], [0, 1], [0, 0]]; const obj = new TestObject(); obj.set('polygon', new Parse.Polygon(coords)); obj.save().then(done.fail, () => done()); });
it('isNew in cloud code', async () => { Parse.Cloud.beforeSave('CloudCodeIsNew', req => { expect(req.object.isNew()).toBeTruthy(); expect(req.object.id).toBeUndefined(); }); Parse.Cloud.afterSave('CloudCodeIsNew', req => { expect(req.object.isNew()).toBeFalsy(); expect(req.object.id).toBeDefined(); }); const object = new Parse.Object('CloudCodeIsNew'); await object.save(); });
beforeEach(async done => { const userACL = new Parse.ACL(); userACL.setPublicReadAccess(true); await user.setACL(userACL).save(null, { useMasterKey: true }); done(); });
it('save file', async () => { const file = new Parse.File('hello.txt', data, 'text/plain'); ok(!file.url()); const result = await file.save(); strictEqual(result, file); ok(file.name()); ok(file.url()); notEqual(file.name(), 'hello.txt'); });
it('does not change inner object keys named _auth_data_something', done => { new Parse.Object('O') .save({ innerObj: { _auth_data_facebook: 7 } }) .then(object => new Parse.Query('O').get(object.id)) .then(object => { expect(object.get('innerObj')).toEqual({ _auth_data_facebook: 7 }); done(); }); });
it("createdAt doesn't change", function(done) { const object = new TestObject({ foo: 'bar' }); object.save().then(function() { const objectAgain = new TestObject(); objectAgain.id = object.id; objectAgain.fetch().then(function() { equal(object.createdAt.getTime(), objectAgain.createdAt.getTime()); done(); }); }); });
it('can set authData when not user class', async () => { const obj = new Parse.Object('TestObject'); obj.set('authData', 'random'); await obj.save(); expect(obj.get('authData')).toBe('random'); const query = new Parse.Query('TestObject'); const object = await query.get(obj.id, { useMasterKey: true }); expect(object.get('authData')).toBe('random'); });
it('distinct createdAt', async () => { const object1 = new TestObject({ createdAt_test: true }); await object1.save(); const object2 = new TestObject({ createdAt_test: true }); await object2.save(); const query = new Parse.Query(TestObject); query.equalTo('createdAt_test', true); const results = await query.distinct('createdAt'); expect(results.length).toBe(2); });
it('invalid key name', function(done) { const item = new Parse.Object('Item'); ok( !item.set({ 'foo^bar': 'baz' }), 'Item should not be updated with invalid key.' ); item.save({ 'foo^bar': 'baz' }).then(fail, () => done()); });
it('save adds no data keys (other than createdAt and updatedAt)', function(done) { const object = new TestObject(); object.save().then(function() { const keys = Object.keys(object.attributes).sort(); equal(keys.length, 2); done(); }); });
it('query notContainedIn on empty array', async () => { const object = new TestObject(); object.set('value', 100); await object.save(); const query = new Parse.Query(TestObject); query.notContainedIn('value', []); const results = await query.find(); equal(results.length, 1); });