From 7223e9dfece4eff0e9af230a3887e6dc40ddba97 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Thu, 12 Dec 2024 18:11:58 +0300 Subject: [PATCH] rewrite test --- pkgs/http/test/response_test.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkgs/http/test/response_test.dart b/pkgs/http/test/response_test.dart index e51b49acc1..3ce0c4b9ba 100644 --- a/pkgs/http/test/response_test.dart +++ b/pkgs/http/test/response_test.dart @@ -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'; @@ -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()', () { @@ -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()', () {