@@ -17,6 +17,11 @@ void main() {
1717 expect (request.uri, equals (localhost));
1818 });
1919
20+ test ('has correct body (empty)' , () {
21+ final request = Request ('GET' , localhost);
22+ expect (request.body (), completion (isEmpty));
23+ });
24+
2025 test ('has correct body (string)' , () {
2126 const body = '__test_body__' ;
2227 final request = Request ('GET' , localhost, body: body);
@@ -93,5 +98,45 @@ void main() {
9398 expect (request.method, equals (HttpMethod .put));
9499 });
95100 });
101+
102+ group ('bytes' , () {
103+ test ('has correct body' , () {
104+ final bytes = utf8.encode ('hello' );
105+ final request = Request .get (localhost, body: bytes);
106+ expect (request.bytes (), emits (equals (bytes)));
107+ });
108+ });
109+
110+ group ('json' , () {
111+ test ('has correct body (map)' , () {
112+ final body = < String , dynamic > {'foo' : 'bar' };
113+ final request = Request .get (localhost, body: json.encode (body));
114+ expect (request.json (), completion (equals (body)));
115+ });
116+
117+ test ('has correct body (list)' , () {
118+ final body = < String > ['foo' , 'bar' ];
119+ final request = Request .get (localhost, body: json.encode (body));
120+ expect (request.json (), completion (equals (body)));
121+ });
122+
123+ test ('has correct body (string)' , () {
124+ const body = 'foo' ;
125+ final request = Request .get (localhost, body: json.encode (body));
126+ expect (request.json (), completion (equals (body)));
127+ });
128+
129+ test ('has correct body (number)' , () {
130+ const body = 42.0 ;
131+ final request = Request .get (localhost, body: json.encode (body));
132+ expect (request.json (), completion (equals (body)));
133+ });
134+
135+ test ('has correct body (bool)' , () {
136+ const body = false ;
137+ final request = Request .get (localhost, body: json.encode (body));
138+ expect (request.json (), completion (equals (body)));
139+ });
140+ });
96141 });
97142}
0 commit comments