@@ -1022,6 +1022,84 @@ export class OfflineBatchHandlerTests extends AITestClass {
10221022 } , "Wait for get batch response" + new Date ( ) . toISOString ( ) , 15 , 1000 ) )
10231023 }
10241024 } ) ;
1025+
1026+ this . testCase ( {
1027+ name : "Null Provider: storeBatch rejects and does not throw when provider is null" ,
1028+ test : ( ) => {
1029+ let batchHandler = new OfflineBatchHandler ( ) ;
1030+ // Do not initialize - provider will be null
1031+ let endpoint = DEFAULT_BREEZE_ENDPOINT + DEFAULT_BREEZE_PATH ;
1032+ let evt = TestHelper . mockEvent ( endpoint , 1 , false ) ;
1033+
1034+ doAwaitResponse ( batchHandler . storeBatch ( evt ) , ( res ) => {
1035+ this . ctx . storeBatchDone = true ;
1036+ Assert . ok ( res . rejected , "storeBatch should reject when provider is null" ) ;
1037+ Assert . ok ( res . reason instanceof Error , "rejection reason should be an Error" ) ;
1038+ Assert . ok ( res . reason . message . indexOf ( "No provider" ) > - 1 , "error message should indicate no provider" ) ;
1039+ } ) ;
1040+
1041+ return this . _asyncQueue ( ) . concat ( PollingAssert . asyncTaskPollingAssert ( ( ) => {
1042+ return ! ! this . ctx . storeBatchDone ;
1043+ } , "Wait for storeBatch rejection" + new Date ( ) . toISOString ( ) , 15 , 1000 ) )
1044+ }
1045+ } ) ;
1046+
1047+ this . testCase ( {
1048+ name : "Null Provider: sendNextBatch rejects and does not throw when provider is null" ,
1049+ test : ( ) => {
1050+ let batchHandler = new OfflineBatchHandler ( ) ;
1051+ // Do not initialize - provider will be null
1052+
1053+ doAwaitResponse ( batchHandler . sendNextBatch ( ) , ( res ) => {
1054+ this . ctx . sendNextDone = true ;
1055+ Assert . ok ( res . rejected , "sendNextBatch should reject when provider is null" ) ;
1056+ Assert . ok ( res . reason instanceof Error , "rejection reason should be an Error" ) ;
1057+ Assert . ok ( res . reason . message . indexOf ( "No provider" ) > - 1 , "error message should indicate no provider" ) ;
1058+ } ) ;
1059+
1060+ return this . _asyncQueue ( ) . concat ( PollingAssert . asyncTaskPollingAssert ( ( ) => {
1061+ return ! ! this . ctx . sendNextDone ;
1062+ } , "Wait for sendNextBatch rejection" + new Date ( ) . toISOString ( ) , 15 , 1000 ) )
1063+ }
1064+ } ) ;
1065+
1066+ this . testCase ( {
1067+ name : "Null Provider: hasStoredBatch rejects and does not throw when provider is null" ,
1068+ test : ( ) => {
1069+ let batchHandler = new OfflineBatchHandler ( ) ;
1070+ // Do not initialize - provider will be null
1071+
1072+ doAwaitResponse ( batchHandler . hasStoredBatch ( ) , ( res ) => {
1073+ this . ctx . hasStoredDone = true ;
1074+ Assert . ok ( res . rejected , "hasStoredBatch should reject when provider is null" ) ;
1075+ Assert . ok ( res . reason instanceof Error , "rejection reason should be an Error" ) ;
1076+ Assert . ok ( res . reason . message . indexOf ( "No provider" ) > - 1 , "error message should indicate no provider" ) ;
1077+ } ) ;
1078+
1079+ return this . _asyncQueue ( ) . concat ( PollingAssert . asyncTaskPollingAssert ( ( ) => {
1080+ return ! ! this . ctx . hasStoredDone ;
1081+ } , "Wait for hasStoredBatch rejection" + new Date ( ) . toISOString ( ) , 15 , 1000 ) )
1082+ }
1083+ } ) ;
1084+
1085+ this . testCase ( {
1086+ name : "Null Provider: cleanStorage rejects and does not throw when provider is null" ,
1087+ test : ( ) => {
1088+ let batchHandler = new OfflineBatchHandler ( ) ;
1089+ // Do not initialize - provider will be null
1090+
1091+ doAwaitResponse ( batchHandler . cleanStorage ( ) , ( res ) => {
1092+ this . ctx . cleanDone = true ;
1093+ Assert . ok ( res . rejected , "cleanStorage should reject when provider is null" ) ;
1094+ Assert . ok ( res . reason instanceof Error , "rejection reason should be an Error" ) ;
1095+ Assert . ok ( res . reason . message . indexOf ( "No provider" ) > - 1 , "error message should indicate no provider" ) ;
1096+ } ) ;
1097+
1098+ return this . _asyncQueue ( ) . concat ( PollingAssert . asyncTaskPollingAssert ( ( ) => {
1099+ return ! ! this . ctx . cleanDone ;
1100+ } , "Wait for cleanStorage rejection" + new Date ( ) . toISOString ( ) , 15 , 1000 ) )
1101+ }
1102+ } ) ;
10251103
10261104 }
10271105}
0 commit comments