Skip to content

Commit 0eabc8d

Browse files
committed
Fixed WASM runtime v2
1 parent 7e1bc9f commit 0eabc8d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkgs/http/test/html/cache_test.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@ import 'dart:async';
1010
import 'package:http/browser_client.dart';
1111
import 'package:http/http.dart' as http;
1212
import 'package:http/http.dart';
13+
import 'package:stream_channel/stream_channel.dart';
1314
import 'package:test/test.dart';
1415

1516
import 'utils.dart';
1617

18+
extension on StreamChannel<dynamic> {
19+
/// Handles the Wasm case where the runtime type is actually [double] instead
20+
/// of the JS case where its [int].
21+
Future<int> get firstAsInt async => ((await stream.first) as num).toInt();
22+
}
23+
1724
void main() {
1825
late Uri url;
1926
setUp(() async {
2027
final channel = spawnHybridUri(Uri(path: '/test/stub_server.dart'));
21-
var port = await (channel.stream.first as num).toInt();
28+
var port = await channel.firstAsInt;
2229
url = echoUrl.replace(port: port);
2330
});
2431

0 commit comments

Comments
 (0)