@@ -760,10 +760,10 @@ describe('ParseLiveQueryServer', function () {
760
760
761
761
// Make sure we send command to client, since _matchesACL is async, we have to
762
762
// 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 ( ) ;
767
767
} ) ;
768
768
769
769
it ( 'has no subscription and can handle object save command' , async ( ) => {
@@ -795,14 +795,14 @@ describe('ParseLiveQueryServer', function () {
795
795
parseLiveQueryServer . _onAfterSave ( message ) ;
796
796
797
797
// 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 ( ) ;
806
806
} ) ;
807
807
808
808
it ( 'can handle object enter command which matches some subscriptions' , async done => {
@@ -832,14 +832,14 @@ describe('ParseLiveQueryServer', function () {
832
832
parseLiveQueryServer . _onAfterSave ( message ) ;
833
833
834
834
// 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 ( ) ;
843
843
} ) ;
844
844
845
845
it ( 'can handle object update command which matches some subscriptions' , async done => {
@@ -865,14 +865,14 @@ describe('ParseLiveQueryServer', function () {
865
865
parseLiveQueryServer . _onAfterSave ( message ) ;
866
866
867
867
// 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 ( ) ;
876
876
} ) ;
877
877
878
878
it ( 'can handle object leave command which matches some subscriptions' , async done => {
@@ -902,17 +902,17 @@ describe('ParseLiveQueryServer', function () {
902
902
parseLiveQueryServer . _onAfterSave ( message ) ;
903
903
904
904
// 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 ( ) ;
913
913
} ) ;
914
914
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 => {
916
916
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
917
917
918
918
Parse . Cloud . afterLiveQueryEvent ( 'TestObject' , ( ) => {
@@ -959,24 +959,24 @@ describe('ParseLiveQueryServer', function () {
959
959
parseLiveQueryServer . _onAfterSave ( message ) ;
960
960
961
961
// 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 ( ) ;
980
980
} ) ;
981
981
982
982
it ( 'can handle update command with original object' , async done => {
@@ -1013,15 +1013,15 @@ describe('ParseLiveQueryServer', function () {
1013
1013
parseLiveQueryServer . _onAfterSave ( message ) ;
1014
1014
1015
1015
// 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 ) ;
1020
1017
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 ( ) ;
1025
1025
} ) ;
1026
1026
1027
1027
it ( 'can handle object create command which matches some subscriptions' , async done => {
@@ -1047,14 +1047,14 @@ describe('ParseLiveQueryServer', function () {
1047
1047
parseLiveQueryServer . _onAfterSave ( message ) ;
1048
1048
1049
1049
// 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 ( ) ;
1058
1058
} ) ;
1059
1059
1060
1060
it ( 'can handle create command with fields' , async done => {
@@ -1097,14 +1097,14 @@ describe('ParseLiveQueryServer', function () {
1097
1097
parseLiveQueryServer . _onAfterSave ( message ) ;
1098
1098
1099
1099
// 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 ( ) ;
1108
1108
} ) ;
1109
1109
1110
1110
it ( 'can match subscription for null or undefined parse object' , function ( ) {
0 commit comments