@@ -232,7 +232,7 @@ describe('ParseLiveQueryServer', function () {
232232 classNames : [ 'Yolo' ] ,
233233 } ,
234234 } )
235- . then ( parseServer => {
235+ . then ( ( parseServer ) => {
236236 saveSpy = spyOn ( parseServer . config . liveQueryController , 'onAfterSave' ) ;
237237 deleteSpy = spyOn (
238238 parseServer . config . liveQueryController ,
@@ -247,7 +247,7 @@ describe('ParseLiveQueryServer', function () {
247247 const obj = new Parse . Object ( 'Yolo' ) ;
248248 return obj . save ( ) ;
249249 } )
250- . then ( obj => {
250+ . then ( ( obj ) => {
251251 return obj . destroy ( ) ;
252252 } )
253253 . then ( ( ) => {
@@ -307,52 +307,6 @@ describe('ParseLiveQueryServer', function () {
307307 expect ( client . pushConnect ) . toHaveBeenCalled ( ) ;
308308 } ) ;
309309
310- it ( 'basic beforeConnect rejection' , async ( ) => {
311- Parse . Cloud . beforeConnect ( function ( ) {
312- throw new Error ( 'You shall not pass!' ) ;
313- } ) ;
314- const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
315- const parseWebSocket = {
316- clientId : - 1 ,
317- } ;
318- await parseLiveQueryServer . _handleConnect ( parseWebSocket , {
319- sessionToken : 'token' ,
320- } ) ;
321- expect ( parseLiveQueryServer . clients . size ) . toBe ( 0 ) ;
322- const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
323- expect ( Client . pushError ) . toHaveBeenCalled ( ) ;
324- } ) ;
325-
326- it ( 'basic beforeSubscribe rejection' , async ( ) => {
327- Parse . Cloud . beforeSubscribe ( 'test' , function ( ) {
328- throw new Error ( 'You shall not pass!' ) ;
329- } ) ;
330- const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
331- const parseWebSocket = {
332- clientId : - 1 ,
333- } ;
334- await parseLiveQueryServer . _handleConnect ( parseWebSocket , {
335- sessionToken : 'token' ,
336- } ) ;
337- const query = {
338- className : 'test' ,
339- where : {
340- key : 'value' ,
341- } ,
342- fields : [ 'test' ] ,
343- } ;
344- const requestId = 2 ;
345- const request = {
346- query : query ,
347- requestId : requestId ,
348- sessionToken : 'sessionToken' ,
349- } ;
350- await parseLiveQueryServer . _handleSubscribe ( parseWebSocket , request ) ;
351- expect ( parseLiveQueryServer . clients . size ) . toBe ( 1 ) ;
352- const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
353- expect ( Client . pushError ) . toHaveBeenCalled ( ) ;
354- } ) ;
355-
356310 it ( 'can handle subscribe command without clientId' , async ( ) => {
357311 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
358312 const incompleteParseConn = { } ;
@@ -775,7 +729,7 @@ describe('ParseLiveQueryServer', function () {
775729 expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
776730 } ) ;
777731
778- it ( 'can handle object delete command which matches some subscriptions' , async done => {
732+ it ( 'can handle object delete command which matches some subscriptions' , async ( done ) => {
779733 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
780734 // Make deletedParseObject
781735 const parseObject = new Parse . Object ( testClassName ) ;
@@ -819,7 +773,7 @@ describe('ParseLiveQueryServer', function () {
819773 parseLiveQueryServer . _onAfterSave ( message ) ;
820774 } ) ;
821775
822- it ( 'can handle object save command which does not match any subscription' , async done => {
776+ it ( 'can handle object save command which does not match any subscription' , async ( done ) => {
823777 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
824778 // Make mock request message
825779 const message = generateMockMessage ( ) ;
@@ -850,7 +804,7 @@ describe('ParseLiveQueryServer', function () {
850804 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
851805 } ) ;
852806
853- it ( 'can handle object enter command which matches some subscriptions' , async done => {
807+ it ( 'can handle object enter command which matches some subscriptions' , async ( done ) => {
854808 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
855809 // Make mock request message
856810 const message = generateMockMessage ( true ) ;
@@ -887,7 +841,7 @@ describe('ParseLiveQueryServer', function () {
887841 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
888842 } ) ;
889843
890- it ( 'can handle object update command which matches some subscriptions' , async done => {
844+ it ( 'can handle object update command which matches some subscriptions' , async ( done ) => {
891845 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
892846 // Make mock request message
893847 const message = generateMockMessage ( true ) ;
@@ -920,7 +874,7 @@ describe('ParseLiveQueryServer', function () {
920874 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
921875 } ) ;
922876
923- it ( 'can handle object leave command which matches some subscriptions' , async done => {
877+ it ( 'can handle object leave command which matches some subscriptions' , async ( done ) => {
924878 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
925879 // Make mock request message
926880 const message = generateMockMessage ( true ) ;
@@ -957,7 +911,7 @@ describe('ParseLiveQueryServer', function () {
957911 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
958912 } ) ;
959913
960- it ( 'can handle update command with original object' , async done => {
914+ it ( 'can handle update command with original object' , async ( done ) => {
961915 jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
962916 const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
963917 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
@@ -1007,7 +961,7 @@ describe('ParseLiveQueryServer', function () {
1007961 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
1008962 } ) ;
1009963
1010- it ( 'can handle object create command which matches some subscriptions' , async done => {
964+ it ( 'can handle object create command which matches some subscriptions' , async ( done ) => {
1011965 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1012966 // Make mock request message
1013967 const message = generateMockMessage ( ) ;
@@ -1040,7 +994,7 @@ describe('ParseLiveQueryServer', function () {
1040994 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
1041995 } ) ;
1042996
1043- it ( 'can handle create command with fields' , async done => {
997+ it ( 'can handle create command with fields' , async ( done ) => {
1044998 jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
1045999 const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
10461000 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
@@ -1546,7 +1500,7 @@ describe('ParseLiveQueryServer', function () {
15461500 } ) ;
15471501
15481502 describe ( 'class level permissions' , ( ) => {
1549- it ( 'matches CLP when find is closed' , done => {
1503+ it ( 'matches CLP when find is closed' , ( done ) => {
15501504 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
15511505 const acl = new Parse . ACL ( ) ;
15521506 acl . setReadAccess ( testUserId , true ) ;
@@ -1571,13 +1525,13 @@ describe('ParseLiveQueryServer', function () {
15711525 requestId ,
15721526 'find'
15731527 )
1574- . then ( isMatched => {
1528+ . then ( ( isMatched ) => {
15751529 expect ( isMatched ) . toBe ( false ) ;
15761530 done ( ) ;
15771531 } ) ;
15781532 } ) ;
15791533
1580- it ( 'matches CLP when find is open' , done => {
1534+ it ( 'matches CLP when find is open' , ( done ) => {
15811535 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
15821536 const acl = new Parse . ACL ( ) ;
15831537 acl . setReadAccess ( testUserId , true ) ;
@@ -1602,13 +1556,13 @@ describe('ParseLiveQueryServer', function () {
16021556 requestId ,
16031557 'find'
16041558 )
1605- . then ( isMatched => {
1559+ . then ( ( isMatched ) => {
16061560 expect ( isMatched ) . toBe ( true ) ;
16071561 done ( ) ;
16081562 } ) ;
16091563 } ) ;
16101564
1611- it ( 'matches CLP when find is restricted to userIds' , done => {
1565+ it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
16121566 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
16131567 const acl = new Parse . ACL ( ) ;
16141568 acl . setReadAccess ( testUserId , true ) ;
@@ -1633,13 +1587,13 @@ describe('ParseLiveQueryServer', function () {
16331587 requestId ,
16341588 'find'
16351589 )
1636- . then ( isMatched => {
1590+ . then ( ( isMatched ) => {
16371591 expect ( isMatched ) . toBe ( true ) ;
16381592 done ( ) ;
16391593 } ) ;
16401594 } ) ;
16411595
1642- it ( 'matches CLP when find is restricted to userIds' , done => {
1596+ it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
16431597 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
16441598 const acl = new Parse . ACL ( ) ;
16451599 acl . setReadAccess ( testUserId , true ) ;
@@ -1664,7 +1618,7 @@ describe('ParseLiveQueryServer', function () {
16641618 requestId ,
16651619 'find'
16661620 )
1667- . then ( isMatched => {
1621+ . then ( ( isMatched ) => {
16681622 expect ( isMatched ) . toBe ( false ) ;
16691623 done ( ) ;
16701624 } ) ;
@@ -2001,7 +1955,7 @@ describe('LiveQueryController', () => {
20011955 classNames : [ 'Yolo' ] ,
20021956 } ,
20031957 } )
2004- . then ( parseServer => {
1958+ . then ( ( parseServer ) => {
20051959 saveSpy = spyOn (
20061960 parseServer . config . liveQueryController ,
20071961 'onAfterSave'
@@ -2019,7 +1973,7 @@ describe('LiveQueryController', () => {
20191973 const obj = new Parse . Object ( 'Yolo' ) ;
20201974 return obj . save ( ) ;
20211975 } )
2022- . then ( obj => {
1976+ . then ( ( obj ) => {
20231977 return obj . destroy ( ) ;
20241978 } )
20251979 . then ( ( ) => {
@@ -2099,3 +2053,49 @@ describe('LiveQueryController', () => {
20992053 } ) ;
21002054 } ) ;
21012055} ) ;
2056+
2057+ it ( 'basic beforeConnect rejection' , async ( ) => {
2058+ Parse . Cloud . beforeConnect ( function ( ) {
2059+ throw new Error ( 'You shall not pass!' ) ;
2060+ } ) ;
2061+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
2062+ const parseWebSocket = {
2063+ clientId : - 1 ,
2064+ } ;
2065+ await parseLiveQueryServer . _handleConnect ( parseWebSocket , {
2066+ sessionToken : 'token' ,
2067+ } ) ;
2068+ expect ( parseLiveQueryServer . clients . size ) . toBe ( 0 ) ;
2069+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
2070+ expect ( Client . pushError ) . toHaveBeenCalled ( ) ;
2071+ } ) ;
2072+
2073+ it ( 'basic beforeSubscribe rejection' , async ( ) => {
2074+ Parse . Cloud . beforeSubscribe ( 'test' , function ( ) {
2075+ throw new Error ( 'You shall not pass!' ) ;
2076+ } ) ;
2077+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
2078+ const parseWebSocket = {
2079+ clientId : - 1 ,
2080+ } ;
2081+ await parseLiveQueryServer . _handleConnect ( parseWebSocket , {
2082+ sessionToken : 'token' ,
2083+ } ) ;
2084+ const query = {
2085+ className : 'test' ,
2086+ where : {
2087+ key : 'value' ,
2088+ } ,
2089+ fields : [ 'test' ] ,
2090+ } ;
2091+ const requestId = 2 ;
2092+ const request = {
2093+ query : query ,
2094+ requestId : requestId ,
2095+ sessionToken : 'sessionToken' ,
2096+ } ;
2097+ await parseLiveQueryServer . _handleSubscribe ( parseWebSocket , request ) ;
2098+ expect ( parseLiveQueryServer . clients . size ) . toBe ( 0 ) ;
2099+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
2100+ expect ( Client . pushError ) . toHaveBeenCalled ( ) ;
2101+ } ) ;
0 commit comments