OLD | NEW |
(Empty) | |
| 1 library http_base.http_base_html_test; |
| 2 |
| 3 import 'dart:html'; |
| 4 import 'dart:async'; |
| 5 import 'dart:convert'; |
| 6 |
| 7 import 'package:http_base/http_base_html.dart'; |
| 8 import 'package:unittest/unittest.dart'; |
| 9 |
| 10 main() { |
| 11 test('http-client', () { |
| 12 var uri = Uri.parse(window.location.href).resolve('/echo'); |
| 13 |
| 14 var client = new Client(); |
| 15 var body = (new StreamController() |
| 16 ..add(UTF8.encode('my-data')) |
| 17 ..close()).stream; |
| 18 var request = new RequestImpl('POST', uri, body: body); |
| 19 client(request).then(expectAsync((response) { |
| 20 expect(response.statusCode, equals(200)); |
| 21 response.read() |
| 22 .transform(UTF8.decoder).join('').then(expectAsync((data) { |
| 23 expect(data, equals('my-data')); |
| 24 })); |
| 25 })); |
| 26 }); |
| 27 } |
OLD | NEW |