@@ -760,10 +760,10 @@ describe('ParseLiveQueryServer', function () {
760760
761761 // Make sure we send command to client, since _matchesACL is async, we have to
762762 // wait and check
763- setTimeout ( function ( ) {
764- expect ( client . pushDelete ) . toHaveBeenCalled ( ) ;
765- done ( ) ;
766- } , ASYNC_TEST_WAIT_TIME ) ;
763+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
764+
765+ expect ( client . pushDelete ) . toHaveBeenCalled ( ) ;
766+ done ( ) ;
767767 } ) ;
768768
769769 it ( 'has no subscription and can handle object save command' , async ( ) => {
@@ -795,14 +795,14 @@ describe('ParseLiveQueryServer', function () {
795795 parseLiveQueryServer . _onAfterSave ( message ) ;
796796
797797 // Make sure we do not send command to client
798- setTimeout ( function ( ) {
799- expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
800- expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
801- expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
802- expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
803- expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
804- done ( ) ;
805- } , ASYNC_TEST_WAIT_TIME ) ;
798+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
799+
800+ expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
801+ expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
802+ expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
803+ expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
804+ expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
805+ done ( ) ;
806806 } ) ;
807807
808808 it ( 'can handle object enter command which matches some subscriptions' , async done => {
@@ -832,14 +832,14 @@ describe('ParseLiveQueryServer', function () {
832832 parseLiveQueryServer . _onAfterSave ( message ) ;
833833
834834 // Make sure we send enter command to client
835- setTimeout ( function ( ) {
836- expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
837- expect ( client . pushEnter ) . toHaveBeenCalled ( ) ;
838- expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
839- expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
840- expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
841- done ( ) ;
842- } , ASYNC_TEST_WAIT_TIME ) ;
835+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
836+
837+ expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
838+ expect ( client . pushEnter ) . toHaveBeenCalled ( ) ;
839+ expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
840+ expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
841+ expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
842+ done ( ) ;
843843 } ) ;
844844
845845 it ( 'can handle object update command which matches some subscriptions' , async done => {
@@ -865,14 +865,14 @@ describe('ParseLiveQueryServer', function () {
865865 parseLiveQueryServer . _onAfterSave ( message ) ;
866866
867867 // Make sure we send update command to client
868- setTimeout ( function ( ) {
869- expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
870- expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
871- expect ( client . pushUpdate ) . toHaveBeenCalled ( ) ;
872- expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
873- expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
874- done ( ) ;
875- } , ASYNC_TEST_WAIT_TIME ) ;
868+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
869+
870+ expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
871+ expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
872+ expect ( client . pushUpdate ) . toHaveBeenCalled ( ) ;
873+ expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
874+ expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
875+ done ( ) ;
876876 } ) ;
877877
878878 it ( 'can handle object leave command which matches some subscriptions' , async done => {
@@ -902,17 +902,17 @@ describe('ParseLiveQueryServer', function () {
902902 parseLiveQueryServer . _onAfterSave ( message ) ;
903903
904904 // Make sure we send leave command to client
905- setTimeout ( function ( ) {
906- expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
907- expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
908- expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
909- expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
910- expect ( client . pushLeave ) . toHaveBeenCalled ( ) ;
911- done ( ) ;
912- } , ASYNC_TEST_WAIT_TIME ) ;
905+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
906+
907+ expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
908+ expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
909+ expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
910+ expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
911+ expect ( client . pushLeave ) . toHaveBeenCalled ( ) ;
912+ done ( ) ;
913913 } ) ;
914914
915- it ( 'can handle object multiple commands which matches some subscriptions' , async done => {
915+ it ( 'sends correct events for object with multiple subscriptions' , async done => {
916916 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
917917
918918 Parse . Cloud . afterLiveQueryEvent ( 'TestObject' , ( ) => {
@@ -959,24 +959,24 @@ describe('ParseLiveQueryServer', function () {
959959 parseLiveQueryServer . _onAfterSave ( message ) ;
960960
961961 // Make sure we send leave and enter command to client
962- setTimeout ( function ( ) {
963- expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
964- expect ( client . pushEnter ) . toHaveBeenCalledTimes ( 1 ) ;
965- expect ( client . pushEnter ) . toHaveBeenCalledWith (
966- requestId3 ,
967- { key : 'value' , className : 'TestObject' } ,
968- { key : 'originalValue ' , className : 'TestObject' }
969- ) ;
970- expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
971- expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
972- expect ( client . pushLeave ) . toHaveBeenCalledTimes ( 1 ) ;
973- expect ( client . pushLeave ) . toHaveBeenCalledWith (
974- requestId2 ,
975- { key : 'value' , className : 'TestObject' } ,
976- { key : 'originalValue ' , className : 'TestObject' }
977- ) ;
978- done ( ) ;
979- } , ASYNC_TEST_WAIT_TIME ) ;
962+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
963+
964+ expect ( client . pushCreate ) . not . toHaveBeenCalled ( ) ;
965+ expect ( client . pushEnter ) . toHaveBeenCalledTimes ( 1 ) ;
966+ expect ( client . pushEnter ) . toHaveBeenCalledWith (
967+ requestId3 ,
968+ { key : 'value ' , className : 'TestObject' } ,
969+ { key : 'originalValue' , className : 'TestObject' }
970+ ) ;
971+ expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
972+ expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
973+ expect ( client . pushLeave ) . toHaveBeenCalledTimes ( 1 ) ;
974+ expect ( client . pushLeave ) . toHaveBeenCalledWith (
975+ requestId2 ,
976+ { key : 'value ' , className : 'TestObject' } ,
977+ { key : 'originalValue' , className : 'TestObject' }
978+ ) ;
979+ done ( ) ;
980980 } ) ;
981981
982982 it ( 'can handle update command with original object' , async done => {
@@ -1013,15 +1013,15 @@ describe('ParseLiveQueryServer', function () {
10131013 parseLiveQueryServer . _onAfterSave ( message ) ;
10141014
10151015 // Make sure we send update command to client
1016- setTimeout ( function ( ) {
1017- expect ( client . pushUpdate ) . toHaveBeenCalled ( ) ;
1018- const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
1019- const toSend = JSON . parse ( args [ 0 ] ) ;
1016+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
10201017
1021- expect ( toSend . object ) . toBeDefined ( ) ;
1022- expect ( toSend . original ) . toBeDefined ( ) ;
1023- done ( ) ;
1024- } , ASYNC_TEST_WAIT_TIME ) ;
1018+ expect ( client . pushUpdate ) . toHaveBeenCalled ( ) ;
1019+ const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
1020+ const toSend = JSON . parse ( args [ 0 ] ) ;
1021+
1022+ expect ( toSend . object ) . toBeDefined ( ) ;
1023+ expect ( toSend . original ) . toBeDefined ( ) ;
1024+ done ( ) ;
10251025 } ) ;
10261026
10271027 it ( 'can handle object create command which matches some subscriptions' , async done => {
@@ -1047,14 +1047,14 @@ describe('ParseLiveQueryServer', function () {
10471047 parseLiveQueryServer . _onAfterSave ( message ) ;
10481048
10491049 // Make sure we send create command to client
1050- setTimeout ( function ( ) {
1051- expect ( client . pushCreate ) . toHaveBeenCalled ( ) ;
1052- expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
1053- expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
1054- expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
1055- expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
1056- done ( ) ;
1057- } , ASYNC_TEST_WAIT_TIME ) ;
1050+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
1051+
1052+ expect ( client . pushCreate ) . toHaveBeenCalled ( ) ;
1053+ expect ( client . pushEnter ) . not . toHaveBeenCalled ( ) ;
1054+ expect ( client . pushUpdate ) . not . toHaveBeenCalled ( ) ;
1055+ expect ( client . pushDelete ) . not . toHaveBeenCalled ( ) ;
1056+ expect ( client . pushLeave ) . not . toHaveBeenCalled ( ) ;
1057+ done ( ) ;
10581058 } ) ;
10591059
10601060 it ( 'can handle create command with fields' , async done => {
@@ -1097,14 +1097,14 @@ describe('ParseLiveQueryServer', function () {
10971097 parseLiveQueryServer . _onAfterSave ( message ) ;
10981098
10991099 // Make sure we send create command to client
1100- setTimeout ( function ( ) {
1101- expect ( client . pushCreate ) . toHaveBeenCalled ( ) ;
1102- const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
1103- const toSend = JSON . parse ( args [ 0 ] ) ;
1104- expect ( toSend . object ) . toBeDefined ( ) ;
1105- expect ( toSend . original ) . toBeUndefined ( ) ;
1106- done ( ) ;
1107- } , ASYNC_TEST_WAIT_TIME ) ;
1100+ await resolveAfter ( null , ASYNC_TEST_WAIT_TIME ) ;
1101+
1102+ expect ( client . pushCreate ) . toHaveBeenCalled ( ) ;
1103+ const args = parseWebSocket . send . calls . mostRecent ( ) . args ;
1104+ const toSend = JSON . parse ( args [ 0 ] ) ;
1105+ expect ( toSend . object ) . toBeDefined ( ) ;
1106+ expect ( toSend . original ) . toBeUndefined ( ) ;
1107+ done ( ) ;
11081108 } ) ;
11091109
11101110 it ( 'can match subscription for null or undefined parse object' , function ( ) {
0 commit comments