// AMD. Register as an anonymous module. define( function() { root.Reveal = factory(); return root.Reveal; } );
describe('cloud functions', () => { it('Should have request ip', done => { Parse.Cloud.define('myFunction', req => { expect(req.ip).toBeDefined(); return 'success'; }); Parse.Cloud.run('myFunction', {}).then(() => done()); }); });
it('should have access to context when cloud function is called.', async () => { Parse.Cloud.define('contextTest', async (req) => { expect(req.context.a).toEqual('a'); return {}; }); await Parse.Cloud.run('contextTest', {}, { context: { a: 'a' } }); });
define(function toString() { var R = anObject(this); return '/'.concat(R.source, '/', 'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined); });
it('cloud function should obfuscate password', done => { Parse.Cloud.define('testFunction', () => { return 'verify code success'; }); Parse.Cloud.run('testFunction', { username: 'hawk', password: '123456' }) .then(() => { const entry = spy.calls.mostRecent().args; expect(entry[2].params.password).toMatch(/\*\*\*\*\*\*\*\*/); done(); }) .then(null, e => done.fail(e)); });
it('should properly create an object in before save', done => { Parse.Cloud.beforeSave('BeforeSaveChanged', function(req) { req.object.set('foo', 'baz'); }); Parse.Cloud.define('createBeforeSaveChangedObject', function() { const obj = new Parse.Object('BeforeSaveChanged'); return obj.save().then(() => { return obj; }); }); Parse.Cloud.run('createBeforeSaveChangedObject').then(res => { expect(res.get('foo')).toEqual('baz'); done(); }); });
it('should log cloud function success', done => { Parse.Cloud.define('aFunction', () => { return 'it worked!'; }); Parse.Cloud.run('aFunction', { foo: 'bar' }).then(() => { const log = spy.calls.mostRecent().args; expect(log[0]).toEqual('info'); expect(log[1]).toMatch( /Ran cloud function aFunction for user [^ ]* with:\n {2}Input: {"foo":"bar"}\n {2}Result: "it worked!/ ); done(); }); });
Parse.Cloud.define('cloudCodeInFile', () => { return 'It is possible to define cloud code in a file.'; });
it('test cloud function should echo keys', function(done) { Parse.Cloud.define('echoKeys', function() { return { applicationId: Parse.applicationId, masterKey: Parse.masterKey, javascriptKey: Parse.javascriptKey, }; }); Parse.Cloud.run('echoKeys').then(result => { expect(result.applicationId).toEqual(Parse.applicationId); expect(result.masterKey).toEqual(Parse.masterKey); expect(result.javascriptKey).toEqual(Parse.javascriptKey); done(); }); });
define(function toString() { return $toString.call(this); });
it('returns an error', done => { Parse.Cloud.define('cloudCodeWithError', () => { /* eslint-disable no-undef */ foo.bar(); /* eslint-enable no-undef */ return 'I better throw an error.'; }); Parse.Cloud.run('cloudCodeWithError').then( () => done.fail('should not succeed'), e => { expect(e).toEqual(new Parse.Error(141, 'foo is not defined')); done(); } ); });
it('can create functions', done => { Parse.Cloud.define('hello', () => { return 'Hello world!'; }); Parse.Cloud.run('hello', {}).then(result => { expect(result).toEqual('Hello world!'); done(); }); });
/*global define */ define( [], function () { return JsDiff; } );
define( "jquery", [], function() { return jQuery; } );
Parse.Cloud.define('cloudCodeInFile', () => { return 'It is possible to define cloud code in a file.'; });