Skip to content

Commit 16fad5d

Browse files
committed
Decrease test timeout to 1 second for faster failures
1 parent bfa5076 commit 16fad5d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Tests/WebViewJavascriptBridgeTests/BridgeTests.m

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,20 @@ - (void)testInitialization
5353
XCTAssertNotNil(bridge);
5454

5555
loadEchoSample(_webView);
56-
[self waitForExpectationsWithTimeout:10 handler:NULL];
56+
[self waitForExpectationsWithTimeout:1 handler:NULL];
57+
}
58+
59+
- (void)testMessageAfterSetup {
60+
WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler];
61+
loadEchoSample(_webView);
62+
XCTestExpectation *callbackInvoked = [self expectationWithDescription:@"Callback invoked"];
63+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 150 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
64+
[bridge send:@"testResponseHandler" responseCallback:^(id responseData) {
65+
XCTAssertEqualObjects(responseData, @"testResponseHandler");
66+
[callbackInvoked fulfill];
67+
}];
68+
});
69+
[self waitForExpectationsWithTimeout:1 handler:NULL];
5770
}
5871

5972
- (void)testResponseHandler
@@ -67,7 +80,7 @@ - (void)testResponseHandler
6780
}];
6881

6982
loadEchoSample(_webView);
70-
[self waitForExpectationsWithTimeout:10 handler:NULL];
83+
[self waitForExpectationsWithTimeout:1 handler:NULL];
7184
}
7285

7386
- (void)testEchoHandler
@@ -81,7 +94,7 @@ - (void)testEchoHandler
8194
}];
8295

8396
loadEchoSample(_webView);
84-
[self waitForExpectationsWithTimeout:10 handler:NULL];
97+
[self waitForExpectationsWithTimeout:1 handler:NULL];
8598
}
8699

87100
- (void)testObjectEncoding
@@ -102,7 +115,7 @@ - (void)testObjectEncoding
102115
echoObject(@{ @"a" : @1, @"b" : @2 });
103116

104117
loadEchoSample(_webView);
105-
[self waitForExpectationsWithTimeout:10 handler:NULL];
118+
[self waitForExpectationsWithTimeout:1 handler:NULL];
106119
}
107120

108121
@end

0 commit comments

Comments
 (0)