@@ -899,6 +899,56 @@ describe('ParseLiveQueryServer', function() {
899899 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
900900 } ) ;
901901
902+ it ( 'can handle update command with original object' , function ( done ) {
903+ jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
904+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
905+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
906+ // Make mock request message
907+ const message = generateMockMessage ( true ) ;
908+
909+ const clientId = 1 ;
910+ const parseWebSocket = {
911+ clientId,
912+ send : jasmine . createSpy ( 'send' ) ,
913+ } ;
914+ const client = new Client ( clientId , parseWebSocket ) ;
915+ spyOn ( client , 'pushUpdate' ) . and . callThrough ( ) ;
916+ parseLiveQueryServer . clients . set ( clientId , client ) ;
917+
918+ // Add mock subscription
919+ const requestId = 2 ;
920+
921+ addMockSubscription (
922+ parseLiveQueryServer ,
923+ clientId ,
924+ requestId ,
925+ parseWebSocket
926+ ) ;
927+ // Mock _matchesSubscription to return matching
928+ parseLiveQueryServer . _matchesSubscription = function ( parseObject ) {
929+ if ( ! parseObject ) {
930+ return false ;
931+ }
932+ return true ;
933+ } ;
934+ parseLiveQueryServer . _matchesACL = function ( ) {
935+ return Promise . resolve ( true ) ;
936+ } ;
937+
938+ parseLiveQueryServer . _onAfterSave ( message ) ;
939+
940+ // Make sure we send update command to client
941+ setTimeout ( function ( ) {
942+ expect ( client . pushUpdate ) . toHaveBeenCalled ( ) ;
943+ const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
944+ const toSend = JSON . parse ( args [ 0 ] ) ;
945+
946+ expect ( toSend . object ) . toBeDefined ( ) ;
947+ expect ( toSend . original ) . toBeDefined ( ) ;
948+ done ( ) ;
949+ } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
950+ } ) ;
951+
902952 it ( 'can handle object create command which matches some subscriptions' , function ( done ) {
903953 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
904954 // Make mock request message
0 commit comments