@@ -294,7 +294,7 @@ describe('ParseLiveQueryServer', function () {
294294 where : {
295295 key : 'value' ,
296296 } ,
297- fields : [ 'test' ] ,
297+ keys : [ 'test' ] ,
298298 } ;
299299 const requestId = 2 ;
300300 const request = {
@@ -331,7 +331,7 @@ describe('ParseLiveQueryServer', function () {
331331 where : {
332332 key : 'value' ,
333333 } ,
334- fields : [ 'test' ] ,
334+ keys : [ 'test' ] ,
335335 } ;
336336 const requestId = 2 ;
337337 const request = {
@@ -378,7 +378,7 @@ describe('ParseLiveQueryServer', function () {
378378 where : {
379379 key : 'value' ,
380380 } ,
381- fields : [ 'test' ] ,
381+ keys : [ 'test' ] ,
382382 } ;
383383 await addMockSubscription ( parseLiveQueryServer , clientId , requestId , parseWebSocket , query ) ;
384384 // Add subscription for mock client 2
@@ -390,7 +390,7 @@ describe('ParseLiveQueryServer', function () {
390390 where : {
391391 key : 'value' ,
392392 } ,
393- fields : [ 'testAgain' ] ,
393+ keys : [ 'testAgain' ] ,
394394 } ;
395395 const requestIdAgain = 1 ;
396396 await addMockSubscription (
@@ -1060,7 +1060,7 @@ describe('ParseLiveQueryServer', function () {
10601060 where : {
10611061 key : 'value' ,
10621062 } ,
1063- fields : [ 'test' ] ,
1063+ keys : [ 'test' ] ,
10641064 } ;
10651065 await addMockSubscription ( parseLiveQueryServer , clientId , requestId , parseWebSocket , query ) ;
10661066 // Mock _matchesSubscription to return matching
@@ -1087,6 +1087,62 @@ describe('ParseLiveQueryServer', function () {
10871087 done ( ) ;
10881088 } ) ;
10891089
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+
10901146 it ( 'can handle create command with watch' , async ( ) => {
10911147 jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
10921148 const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
@@ -1865,7 +1921,7 @@ describe('ParseLiveQueryServer', function () {
18651921 where : {
18661922 key : 'value' ,
18671923 } ,
1868- fields : [ 'test' ] ,
1924+ keys : [ 'test' ] ,
18691925 } ;
18701926 }
18711927 const request = {
0 commit comments