@@ -754,6 +754,58 @@ describe('ParseLiveQueryServer', function () {
754
754
parseLiveQueryServer . _onAfterSave ( message ) ;
755
755
} ) ;
756
756
757
+ fit ( 'sends correct object for dates' , async ( ) => {
758
+ jasmine . restoreLibrary ( '../lib/LiveQuery/QueryTools' , 'matchesQuery' ) ;
759
+
760
+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
761
+
762
+ const date = new Date ( ) ;
763
+ const message = {
764
+ currentParseObject : {
765
+ date : { __type : 'Date' , iso : date . toISOString ( ) } ,
766
+ __type : 'Object' ,
767
+ key : 'value' ,
768
+ className : testClassName ,
769
+ } ,
770
+ } ;
771
+ // Add mock client
772
+ const clientId = 1 ;
773
+ const client = addMockClient ( parseLiveQueryServer , clientId ) ;
774
+
775
+ const requestId2 = 2 ;
776
+
777
+ await addMockSubscription ( parseLiveQueryServer , clientId , requestId2 ) ;
778
+
779
+ parseLiveQueryServer . _matchesSubscription = function ( parseObject , subscription ) {
780
+ if ( ! parseObject ) {
781
+ return false ;
782
+ }
783
+ subscription . query . date = { $exists : true } ;
784
+ const matchesQuery = require ( '../lib/LiveQuery/QueryTools' ) . matchesQuery ;
785
+ matchesQuery ( parseObject , subscription . query ) ;
786
+ return true ;
787
+ } ;
788
+ parseLiveQueryServer . _matchesACL = function ( ) {
789
+ return Promise . resolve ( true ) ;
790
+ } ;
791
+
792
+ parseLiveQueryServer . _inflateParseObject ( message ) ;
793
+ parseLiveQueryServer . _onAfterSave ( message ) ;
794
+
795
+ // Make sure we send leave and enter command to client
796
+ await timeout ( ) ;
797
+
798
+ expect ( client . pushCreate ) . toHaveBeenCalledWith (
799
+ requestId2 ,
800
+ {
801
+ className : 'TestObject' ,
802
+ key : 'value' ,
803
+ date : { __type : 'Date' , iso : date . toISOString ( ) } ,
804
+ } ,
805
+ null
806
+ ) ;
807
+ } ) ;
808
+
757
809
it ( 'can handle object save command which does not match any subscription' , async done => {
758
810
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
759
811
// Make mock request message
@@ -1138,8 +1190,7 @@ describe('ParseLiveQueryServer', function () {
1138
1190
expect ( toSend . original ) . toBeUndefined ( ) ;
1139
1191
expect ( spy ) . toHaveBeenCalledWith ( {
1140
1192
usage : 'Subscribing using fields parameter' ,
1141
- solution :
1142
- `Subscribe using "keys" instead.` ,
1193
+ solution : `Subscribe using "keys" instead.` ,
1143
1194
} ) ;
1144
1195
} ) ;
1145
1196
@@ -1945,6 +1996,7 @@ describe('ParseLiveQueryServer', function () {
1945
1996
} else {
1946
1997
subscription . clientRequestIds = new Map ( [ [ clientId , [ requestId ] ] ] ) ;
1947
1998
}
1999
+ subscription . query = query . where ;
1948
2000
return subscription ;
1949
2001
}
1950
2002
0 commit comments