BVB Source Codes

parse-server Show ParseCloudCodePublisher.spec.js Source code

Return Download parse-server: download ParseCloudCodePublisher.spec.js Source code - Download parse-server Source code - Type:.js
  1. var ParseCloudCodePublisher = require('../src/LiveQuery/ParseCloudCodePublisher').ParseCloudCodePublisher;
  2. var Parse = require('parse/node');
  3.  
  4. describe('ParseCloudCodePublisher', function() {
  5.   beforeEach(function(done) {
  6.     // Mock ParsePubSub
  7.     var mockParsePubSub = {
  8.       createPublisher: jasmine.createSpy('publish').and.returnValue({
  9.         publish: jasmine.createSpy('publish'),
  10.         on: jasmine.createSpy('on')
  11.       }),
  12.       createSubscriber: jasmine.createSpy('publish').and.returnValue({
  13.         subscribe: jasmine.createSpy('subscribe'),
  14.         on: jasmine.createSpy('on')
  15.       })
  16.     };
  17.     jasmine.mockLibrary('../src/LiveQuery/ParsePubSub', 'ParsePubSub', mockParsePubSub);
  18.     done();
  19.   });
  20.  
  21.   it('can initialize', function() {
  22.     var config = {}
  23.     new ParseCloudCodePublisher(config);
  24.  
  25.     var ParsePubSub = require('../src/LiveQuery/ParsePubSub').ParsePubSub;
  26.     expect(ParsePubSub.createPublisher).toHaveBeenCalledWith(config);
  27.   });
  28.  
  29.   it('can handle cloud code afterSave request', function() {
  30.     var publisher = new ParseCloudCodePublisher({});
  31.     publisher._onCloudCodeMessage = jasmine.createSpy('onCloudCodeMessage');
  32.     var request = {};
  33.     publisher.onCloudCodeAfterSave(request);
  34.  
  35.     expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith(Parse.applicationId + 'afterSave', request);
  36.   });
  37.  
  38.   it('can handle cloud code afterDelete request', function() {
  39.     var publisher = new ParseCloudCodePublisher({});
  40.     publisher._onCloudCodeMessage = jasmine.createSpy('onCloudCodeMessage');
  41.     var request = {};
  42.     publisher.onCloudCodeAfterDelete(request);
  43.  
  44.     expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith(Parse.applicationId + 'afterDelete', request);
  45.   });
  46.  
  47.   it('can handle cloud code request', function() {
  48.     var publisher = new ParseCloudCodePublisher({});
  49.     var currentParseObject = new Parse.Object('Test');
  50.     currentParseObject.set('key', 'value');
  51.     var originalParseObject = new Parse.Object('Test');
  52.     originalParseObject.set('key', 'originalValue');
  53.     var request = {
  54.       object: currentParseObject,
  55.       original: originalParseObject
  56.     };
  57.     publisher._onCloudCodeMessage('afterSave', request);
  58.  
  59.     var args = publisher.parsePublisher.publish.calls.mostRecent().args;
  60.     expect(args[0]).toBe('afterSave');
  61.     var message = JSON.parse(args[1]);
  62.     expect(message.currentParseObject).toEqual(request.object._toFullJSON());
  63.     expect(message.originalParseObject).toEqual(request.original._toFullJSON());
  64.   });
  65.  
  66.   afterEach(function(){
  67.     jasmine.restoreLibrary('../src/LiveQuery/ParsePubSub', 'ParsePubSub');
  68.   });
  69. });
  70.  
downloadParseCloudCodePublisher.spec.js Source code - Download parse-server Source code
Related Source Codes/Software:
react-boilerplate - 2017-06-07
webtorrent - Streaming torrent client for the web ... 2017-06-06
machine-learning-for-software-engineers - A complete daily plan for studying to become a mac... 2017-06-06
upterm - A terminal emulator for the 21st century. 2017-06-06
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
storybook - 2017-06-07
prettier - Prettier is an opinionated JavaScript formatter. ... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top