Skip to content

Commit

Permalink
remove magic calculations in send progress test
Browse files Browse the repository at this point in the history
  • Loading branch information
SpeedReach committed Oct 6, 2023
1 parent ee59874 commit 50f0f6a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dio/test/upload_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,30 @@ void main() {
test('send progress', () async {
final data = <Uint8List>[
Uint8List.fromList([10, 1]),
Uint8List.fromList([1, 4]),
Uint8List.fromList([1, 4, 5]),
Uint8List.fromList([5, 1]),
Uint8List.fromList([1, 1]),
Uint8List.fromList([2, 4]),
];
final stream = Stream.fromIterable(data);
final expanded = data.expand((element) => element);
final List<int> collected = [];
final _ = await dio.put(
'/put',
data: stream,
onSendProgress: (a, b) {
expect(b, 10);
expect(b, expanded.length);
collected.add(a);
},
options: Options(
contentType: Headers.textPlainContentType,
headers: {
Headers.contentLengthHeader: data.length * 2, // set content-length
Headers.contentLengthHeader: expanded.length, // set content-length
},
),
);
for (int i = 0; i < data.length; i++) {
expect(collected[i], (i + 1) * 2);
expect(collected[i], data.sublist(0, i + 1).expand((e) => e).length);
}
});
}
Expand Down

0 comments on commit 50f0f6a

Please sign in to comment.