-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathbrowser_test.dart
35 lines (30 loc) · 1.17 KB
/
browser_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@TestOn('browser')
import 'dart:typed_data';
import 'package:dio/browser.dart';
import 'package:dio/dio.dart';
import 'package:test/test.dart';
void main() {
test('with credentials', () async {
final browserAdapter = BrowserHttpClientAdapter(withCredentials: true);
final opts = RequestOptions();
final testStream = Stream<Uint8List>.periodic(
const Duration(seconds: 1),
(x) => Uint8List(x),
);
final cancelFuture = opts.cancelToken?.whenCancel;
browserAdapter.fetch(opts, testStream, cancelFuture);
expect(browserAdapter.xhrs.every((e) => e.withCredentials == true), isTrue);
});
test('ResponseType in blobUrl', () async {
final browserAdapter = BrowserHttpClientAdapter(withCredentials: true);
final opts = RequestOptions(responseType: ResponseType.blobUrl);
final testStream = Stream<Uint8List>.periodic(
const Duration(seconds: 1),
(x) => Uint8List(x),
);
final cancelFuture = opts.cancelToken?.whenCancel;
browserAdapter.fetch(opts, testStream, cancelFuture);
expect(browserAdapter.xhrs.every((e) => e.withCredentials == true), isTrue);
expect(opts.responseType, ResponseType.blobUrl);
});
}