Skip to content

Commit 9168e69

Browse files
authored
test: Webhook overwrites Cloud Code function warning (#10400)
1 parent 6322aab commit 9168e69

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spec/ParseHooks.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,19 @@ describe('Hooks', () => {
635635
done();
636636
});
637637
});
638+
639+
it('should log warning when webhook overwrites existing Cloud Code function', async () => {
640+
const logger = require('../lib/logger').logger;
641+
spyOn(logger, 'warn').and.callFake(() => {});
642+
Parse.Cloud.define('myCloudFunction', () => 'cloud result', { requireMaster: true });
643+
expect(triggers.getFunction('myCloudFunction', Parse.applicationId)).toBeDefined();
644+
expect(triggers.getValidator('myCloudFunction', Parse.applicationId)).toBeDefined();
645+
await Parse.Hooks.createFunction('myCloudFunction', hookServerURL + '/hook');
646+
expect(logger.warn).toHaveBeenCalledWith(
647+
'Warning: Duplicate cloud functions exist for myCloudFunction. Only the last one will be used and the others will be ignored.'
648+
);
649+
await Parse.Hooks.removeFunction('myCloudFunction');
650+
});
638651
});
639652

640653
describe('triggers', () => {

0 commit comments

Comments
 (0)