Skip to content

Commit

Permalink
rewrite test
Browse files Browse the repository at this point in the history
  • Loading branch information
snoopdoggy322 committed Dec 12, 2024
1 parent 8c267c4 commit 7223e9d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkgs/http/test/response_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:test/test.dart';
Expand All @@ -27,12 +28,6 @@ void main() {
headers: {'content-type': 'text/plain; charset=iso-8859-1'});
expect(response.bodyBytes, equals([102, 246, 248, 98, 227, 114]));
});

test('test empty charset', () {
var response = http.Response('{"foo":"Привет, мир!"}', 200,
headers: {'content-type': 'application/json'});
expect(response.body, equals('{"foo":"Привет, мир!"}'));
});
});

group('.bytes()', () {
Expand All @@ -51,6 +46,13 @@ void main() {
headers: {'content-type': 'text/plain; charset=iso-8859-1'});
expect(response.body, equals('föøbãr'));
});
test('test decoding with empty charset if content type is application/json',
() {
final utf8Bytes = utf8.encode('{"foo":"Привет, мир!"}');
var response = http.Response.bytes(utf8Bytes, 200,
headers: {'content-type': 'application/json'});
expect(response.body, equals('{"foo":"Привет, мир!"}'));
});
});

group('.fromStream()', () {
Expand Down

0 comments on commit 7223e9d

Please sign in to comment.