BVB Source Codes

parse-server Show PushRouter.spec.js Source code

Return Download parse-server: download PushRouter.spec.js Source code - Download parse-server Source code - Type:.js
  1. var PushRouter = require('../src/Routers/PushRouter').PushRouter;
  2. var request = require('request');
  3.  
  4. describe('PushRouter', () => {
  5.   it('can get query condition when channels is set', (done) => {
  6.     // Make mock request
  7.     var request = {
  8.       body: {
  9.         channels: ['Giants', 'Mets']
  10.       }
  11.     }
  12.  
  13.     var where = PushRouter.getQueryCondition(request);
  14.     expect(where).toEqual({
  15.       'channels': {
  16.         '$in': ['Giants', 'Mets']
  17.       }
  18.     });
  19.     done();
  20.   });
  21.  
  22.   it('can get query condition when where is set', (done) => {
  23.     // Make mock request
  24.     var request = {
  25.       body: {
  26.         'where': {
  27.           'injuryReports': true
  28.         }
  29.       }
  30.     }
  31.  
  32.     var where = PushRouter.getQueryCondition(request);
  33.     expect(where).toEqual({
  34.       'injuryReports': true
  35.     });
  36.     done();
  37.   });
  38.  
  39.   it('can get query condition when nothing is set', (done) => {
  40.     // Make mock request
  41.     var request = {
  42.       body: {
  43.       }
  44.     }
  45.  
  46.     expect(function() {
  47.       PushRouter.getQueryCondition(request);
  48.     }).toThrow();
  49.     done();
  50.   });
  51.  
  52.   it('can throw on getQueryCondition when channels and where are set', (done) => {
  53.     // Make mock request
  54.     var request = {
  55.       body: {
  56.         'channels': {
  57.           '$in': ['Giants', 'Mets']
  58.         },
  59.         'where': {
  60.           'injuryReports': true
  61.         }
  62.       }
  63.     }
  64.  
  65.     expect(function() {
  66.       PushRouter.getQueryCondition(request);
  67.     }).toThrow();
  68.     done();
  69.   });
  70.  
  71.   it('sends a push through REST', (done) => {
  72.     request.post({
  73.       url: Parse.serverURL + "/push",
  74.       json: true,
  75.       body: {
  76.         'channels': {
  77.           '$in': ['Giants', 'Mets']
  78.         }
  79.       },
  80.       headers: {
  81.         'X-Parse-Application-Id': Parse.applicationId,
  82.         'X-Parse-Master-Key': Parse.masterKey
  83.       }
  84.     }, function(err, res, body){
  85.       expect(res.headers['x-parse-push-status-id']).not.toBe(undefined);
  86.       expect(res.headers['x-parse-push-status-id'].length).toBe(10);
  87.       expect(res.headers[''])
  88.       expect(body.result).toBe(true);
  89.       done();
  90.     });
  91.   });
  92. });
  93.  
downloadPushRouter.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