@@ -294,7 +294,7 @@ describe('ParseLiveQueryServer', function () {
294
294
where : {
295
295
key : 'value' ,
296
296
} ,
297
- fields : [ 'test' ] ,
297
+ keys : [ 'test' ] ,
298
298
} ;
299
299
const requestId = 2 ;
300
300
const request = {
@@ -331,7 +331,7 @@ describe('ParseLiveQueryServer', function () {
331
331
where : {
332
332
key : 'value' ,
333
333
} ,
334
- fields : [ 'test' ] ,
334
+ keys : [ 'test' ] ,
335
335
} ;
336
336
const requestId = 2 ;
337
337
const request = {
@@ -378,7 +378,7 @@ describe('ParseLiveQueryServer', function () {
378
378
where : {
379
379
key : 'value' ,
380
380
} ,
381
- fields : [ 'test' ] ,
381
+ keys : [ 'test' ] ,
382
382
} ;
383
383
await addMockSubscription ( parseLiveQueryServer , clientId , requestId , parseWebSocket , query ) ;
384
384
// Add subscription for mock client 2
@@ -390,7 +390,7 @@ describe('ParseLiveQueryServer', function () {
390
390
where : {
391
391
key : 'value' ,
392
392
} ,
393
- fields : [ 'testAgain' ] ,
393
+ keys : [ 'testAgain' ] ,
394
394
} ;
395
395
const requestIdAgain = 1 ;
396
396
await addMockSubscription (
@@ -1060,7 +1060,7 @@ describe('ParseLiveQueryServer', function () {
1060
1060
where : {
1061
1061
key : 'value' ,
1062
1062
} ,
1063
- fields : [ 'test' ] ,
1063
+ keys : [ 'test' ] ,
1064
1064
} ;
1065
1065
await addMockSubscription ( parseLiveQueryServer , clientId , requestId , parseWebSocket , query ) ;
1066
1066
// Mock _matchesSubscription to return matching
@@ -1087,6 +1087,62 @@ describe('ParseLiveQueryServer', function () {
1087
1087
done ( ) ;
1088
1088
} ) ;
1089
1089
1090
+ it ( 'can deprecate fields' , async ( ) => {
1091
+ const Deprecator = require ( '../lib/Deprecator/Deprecator' ) ;
1092
+ const spy = spyOn ( Deprecator , 'logRuntimeDeprecation' ) . and . callFake ( ( ) => { } ) ;
1093
+ jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
1094
+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
1095
+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1096
+ // Make mock request message
1097
+ const message = generateMockMessage ( ) ;
1098
+
1099
+ const clientId = 1 ;
1100
+ const parseWebSocket = {
1101
+ clientId,
1102
+ send : jasmine . createSpy ( 'send' ) ,
1103
+ } ;
1104
+ const client = new Client ( clientId , parseWebSocket ) ;
1105
+ spyOn ( client , 'pushCreate' ) . and . callThrough ( ) ;
1106
+ parseLiveQueryServer . clients . set ( clientId , client ) ;
1107
+
1108
+ // Add mock subscription
1109
+ const requestId = 2 ;
1110
+ const query = {
1111
+ className : testClassName ,
1112
+ where : {
1113
+ key : 'value' ,
1114
+ } ,
1115
+ fields : [ 'test' ] ,
1116
+ } ;
1117
+ await addMockSubscription ( parseLiveQueryServer , clientId , requestId , parseWebSocket , query ) ;
1118
+ // Mock _matchesSubscription to return matching
1119
+ parseLiveQueryServer . _matchesSubscription = function ( parseObject ) {
1120
+ if ( ! parseObject ) {
1121
+ return false ;
1122
+ }
1123
+ return true ;
1124
+ } ;
1125
+ parseLiveQueryServer . _matchesACL = function ( ) {
1126
+ return Promise . resolve ( true ) ;
1127
+ } ;
1128
+
1129
+ parseLiveQueryServer . _onAfterSave ( message ) ;
1130
+
1131
+ // Make sure we send create command to client
1132
+ await timeout ( ) ;
1133
+
1134
+ expect ( client . pushCreate ) . toHaveBeenCalled ( ) ;
1135
+ const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
1136
+ const toSend = JSON . parse ( args [ 0 ] ) ;
1137
+ expect ( toSend . object ) . toBeDefined ( ) ;
1138
+ expect ( toSend . original ) . toBeUndefined ( ) ;
1139
+ expect ( spy ) . toHaveBeenCalledWith ( {
1140
+ usage : 'Subscribing using fields parameter' ,
1141
+ solution :
1142
+ `Subscribe using "keys" instead.` ,
1143
+ } ) ;
1144
+ } ) ;
1145
+
1090
1146
it ( 'can handle create command with watch' , async ( ) => {
1091
1147
jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
1092
1148
const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
@@ -1865,7 +1921,7 @@ describe('ParseLiveQueryServer', function () {
1865
1921
where : {
1866
1922
key : 'value' ,
1867
1923
} ,
1868
- fields : [ 'test' ] ,
1924
+ keys : [ 'test' ] ,
1869
1925
} ;
1870
1926
}
1871
1927
const request = {
0 commit comments