@@ -989,6 +989,62 @@ describe('ParseLiveQueryServer', function() {
989989 } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
990990 } ) ;
991991
992+ it ( 'can handle create command with fields' , function ( done ) {
993+ jasmine . restoreLibrary ( '../lib/LiveQuery/Client' , 'Client' ) ;
994+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
995+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
996+ // Make mock request message
997+ const message = generateMockMessage ( ) ;
998+
999+ const clientId = 1 ;
1000+ const parseWebSocket = {
1001+ clientId,
1002+ send : jasmine . createSpy ( 'send' ) ,
1003+ } ;
1004+ const client = new Client ( clientId , parseWebSocket ) ;
1005+ spyOn ( client , 'pushCreate' ) . and . callThrough ( ) ;
1006+ parseLiveQueryServer . clients . set ( clientId , client ) ;
1007+
1008+ // Add mock subscription
1009+ const requestId = 2 ;
1010+ const query = {
1011+ className : testClassName ,
1012+ where : {
1013+ key : 'value' ,
1014+ } ,
1015+ fields : [ 'test' ] ,
1016+ } ;
1017+ addMockSubscription (
1018+ parseLiveQueryServer ,
1019+ clientId ,
1020+ requestId ,
1021+ parseWebSocket ,
1022+ query
1023+ ) ;
1024+ // Mock _matchesSubscription to return matching
1025+ parseLiveQueryServer . _matchesSubscription = function ( parseObject ) {
1026+ if ( ! parseObject ) {
1027+ return false ;
1028+ }
1029+ return true ;
1030+ } ;
1031+ parseLiveQueryServer . _matchesACL = function ( ) {
1032+ return Promise . resolve ( true ) ;
1033+ } ;
1034+
1035+ parseLiveQueryServer . _onAfterSave ( message ) ;
1036+
1037+ // Make sure we send create command to client
1038+ setTimeout ( function ( ) {
1039+ expect ( client . pushCreate ) . toHaveBeenCalled ( ) ;
1040+ const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
1041+ const toSend = JSON . parse ( args [ 0 ] ) ;
1042+ expect ( toSend . object ) . toBeDefined ( ) ;
1043+ expect ( toSend . original ) . toBeUndefined ( ) ;
1044+ done ( ) ;
1045+ } , jasmine . ASYNC_TEST_WAIT_TIME ) ;
1046+ } ) ;
1047+
9921048 it ( 'can match subscription for null or undefined parse object' , function ( ) {
9931049 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
9941050 // Make mock subscription
0 commit comments