@@ -232,7 +232,7 @@ describe('ParseLiveQueryServer', function () {
232
232
classNames : [ 'Yolo' ] ,
233
233
} ,
234
234
} )
235
- . then ( ( parseServer ) => {
235
+ . then ( parseServer => {
236
236
saveSpy = spyOn ( parseServer . config . liveQueryController , 'onAfterSave' ) ;
237
237
deleteSpy = spyOn (
238
238
parseServer . config . liveQueryController ,
@@ -247,7 +247,7 @@ describe('ParseLiveQueryServer', function () {
247
247
const obj = new Parse . Object ( 'Yolo' ) ;
248
248
return obj . save ( ) ;
249
249
} )
250
- . then ( ( obj ) => {
250
+ . then ( obj => {
251
251
return obj . destroy ( ) ;
252
252
} )
253
253
. then ( ( ) => {
@@ -307,6 +307,52 @@ describe('ParseLiveQueryServer', function () {
307
307
expect ( client . pushConnect ) . toHaveBeenCalled ( ) ;
308
308
} ) ;
309
309
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
+
310
356
it ( 'can handle subscribe command without clientId' , async ( ) => {
311
357
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
312
358
const incompleteParseConn = { } ;
@@ -729,7 +775,7 @@ describe('ParseLiveQueryServer', function () {
729
775
expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
730
776
} ) ;
731
777
732
- it ( 'can handle object delete command which matches some subscriptions' , async ( done ) => {
778
+ it ( 'can handle object delete command which matches some subscriptions' , async done => {
733
779
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
734
780
// Make deletedParseObject
735
781
const parseObject = new Parse . Object ( testClassName ) ;
@@ -773,7 +819,7 @@ describe('ParseLiveQueryServer', function () {
773
819
parseLiveQueryServer . _onAfterSave ( message ) ;
774
820
} ) ;
775
821
776
- it ( 'can handle object save command which does not match any subscription' , async ( done ) => {
822
+ it ( 'can handle object save command which does not match any subscription' , async done => {
777
823
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
778
824
// Make mock request message
779
825
const message = generateMockMessage ( ) ;
@@ -804,7 +850,7 @@ describe('ParseLiveQueryServer', function () {
804
850
} , jasmine . ASYNC_TEST_WAIT_TIME ) ;
805
851
} ) ;
806
852
807
- it ( 'can handle object enter command which matches some subscriptions' , async ( done ) => {
853
+ it ( 'can handle object enter command which matches some subscriptions' , async done => {
808
854
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
809
855
// Make mock request message
810
856
const message = generateMockMessage ( true ) ;
@@ -841,7 +887,7 @@ describe('ParseLiveQueryServer', function () {
841
887
} , jasmine . ASYNC_TEST_WAIT_TIME ) ;
842
888
} ) ;
843
889
844
- it ( 'can handle object update command which matches some subscriptions' , async ( done ) => {
890
+ it ( 'can handle object update command which matches some subscriptions' , async done => {
845
891
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
846
892
// Make mock request message
847
893
const message = generateMockMessage ( true ) ;
@@ -874,7 +920,7 @@ describe('ParseLiveQueryServer', function () {
874
920
} , jasmine . ASYNC_TEST_WAIT_TIME ) ;
875
921
} ) ;
876
922
877
- it ( 'can handle object leave command which matches some subscriptions' , async ( done ) => {
923
+ it ( 'can handle object leave command which matches some subscriptions' , async done => {
878
924
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
879
925
// Make mock request message
880
926
const message = generateMockMessage ( true ) ;
@@ -911,7 +957,7 @@ describe('ParseLiveQueryServer', function () {
911
957
} , jasmine . ASYNC_TEST_WAIT_TIME ) ;
912
958
} ) ;
913
959
914
- it ( 'can handle update command with original object' , async ( done ) => {
960
+ it ( 'can handle update command with original object' , async done => {
915
961
jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
916
962
const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
917
963
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
@@ -961,7 +1007,7 @@ describe('ParseLiveQueryServer', function () {
961
1007
} , jasmine . ASYNC_TEST_WAIT_TIME ) ;
962
1008
} ) ;
963
1009
964
- it ( 'can handle object create command which matches some subscriptions' , async ( done ) => {
1010
+ it ( 'can handle object create command which matches some subscriptions' , async done => {
965
1011
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
966
1012
// Make mock request message
967
1013
const message = generateMockMessage ( ) ;
@@ -994,7 +1040,7 @@ describe('ParseLiveQueryServer', function () {
994
1040
} , jasmine . ASYNC_TEST_WAIT_TIME ) ;
995
1041
} ) ;
996
1042
997
- it ( 'can handle create command with fields' , async ( done ) => {
1043
+ it ( 'can handle create command with fields' , async done => {
998
1044
jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
999
1045
const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
1000
1046
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
@@ -1500,7 +1546,7 @@ describe('ParseLiveQueryServer', function () {
1500
1546
} ) ;
1501
1547
1502
1548
describe ( 'class level permissions' , ( ) => {
1503
- it ( 'matches CLP when find is closed' , ( done ) => {
1549
+ it ( 'matches CLP when find is closed' , done => {
1504
1550
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1505
1551
const acl = new Parse . ACL ( ) ;
1506
1552
acl . setReadAccess ( testUserId , true ) ;
@@ -1525,13 +1571,13 @@ describe('ParseLiveQueryServer', function () {
1525
1571
requestId ,
1526
1572
'find'
1527
1573
)
1528
- . then ( ( isMatched ) => {
1574
+ . then ( isMatched => {
1529
1575
expect ( isMatched ) . toBe ( false ) ;
1530
1576
done ( ) ;
1531
1577
} ) ;
1532
1578
} ) ;
1533
1579
1534
- it ( 'matches CLP when find is open' , ( done ) => {
1580
+ it ( 'matches CLP when find is open' , done => {
1535
1581
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1536
1582
const acl = new Parse . ACL ( ) ;
1537
1583
acl . setReadAccess ( testUserId , true ) ;
@@ -1556,13 +1602,13 @@ describe('ParseLiveQueryServer', function () {
1556
1602
requestId ,
1557
1603
'find'
1558
1604
)
1559
- . then ( ( isMatched ) => {
1605
+ . then ( isMatched => {
1560
1606
expect ( isMatched ) . toBe ( true ) ;
1561
1607
done ( ) ;
1562
1608
} ) ;
1563
1609
} ) ;
1564
1610
1565
- it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
1611
+ it ( 'matches CLP when find is restricted to userIds' , done => {
1566
1612
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1567
1613
const acl = new Parse . ACL ( ) ;
1568
1614
acl . setReadAccess ( testUserId , true ) ;
@@ -1587,13 +1633,13 @@ describe('ParseLiveQueryServer', function () {
1587
1633
requestId ,
1588
1634
'find'
1589
1635
)
1590
- . then ( ( isMatched ) => {
1636
+ . then ( isMatched => {
1591
1637
expect ( isMatched ) . toBe ( true ) ;
1592
1638
done ( ) ;
1593
1639
} ) ;
1594
1640
} ) ;
1595
1641
1596
- it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
1642
+ it ( 'matches CLP when find is restricted to userIds' , done => {
1597
1643
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1598
1644
const acl = new Parse . ACL ( ) ;
1599
1645
acl . setReadAccess ( testUserId , true ) ;
@@ -1618,7 +1664,7 @@ describe('ParseLiveQueryServer', function () {
1618
1664
requestId ,
1619
1665
'find'
1620
1666
)
1621
- . then ( ( isMatched ) => {
1667
+ . then ( isMatched => {
1622
1668
expect ( isMatched ) . toBe ( false ) ;
1623
1669
done ( ) ;
1624
1670
} ) ;
@@ -1955,7 +2001,7 @@ describe('LiveQueryController', () => {
1955
2001
classNames : [ 'Yolo' ] ,
1956
2002
} ,
1957
2003
} )
1958
- . then ( ( parseServer ) => {
2004
+ . then ( parseServer => {
1959
2005
saveSpy = spyOn (
1960
2006
parseServer . config . liveQueryController ,
1961
2007
'onAfterSave'
@@ -1973,7 +2019,7 @@ describe('LiveQueryController', () => {
1973
2019
const obj = new Parse . Object ( 'Yolo' ) ;
1974
2020
return obj . save ( ) ;
1975
2021
} )
1976
- . then ( ( obj ) => {
2022
+ . then ( obj => {
1977
2023
return obj . destroy ( ) ;
1978
2024
} )
1979
2025
. then ( ( ) => {
@@ -2053,49 +2099,3 @@ describe('LiveQueryController', () => {
2053
2099
} ) ;
2054
2100
} ) ;
2055
2101
} ) ;
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