| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library shelf.hijack_test; | 5 library shelf.hijack_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:shelf/shelf.dart'; | 10 import 'package:shelf/shelf.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 expect(() => request.hijack((_, __) => null), | 46 expect(() => request.hijack((_, __) => null), |
| 47 throwsA(new isInstanceOf<HijackException>())); | 47 throwsA(new isInstanceOf<HijackException>())); |
| 48 | 48 |
| 49 expect(() => request.hijack((_, __) => null), throwsStateError); | 49 expect(() => request.hijack((_, __) => null), throwsStateError); |
| 50 }); | 50 }); |
| 51 | 51 |
| 52 group('calling change', () { | 52 group('calling change', () { |
| 53 test('hijacking a non-hijackable request throws a StateError', () { | 53 test('hijacking a non-hijackable request throws a StateError', () { |
| 54 var request = new Request('GET', LOCALHOST_URI); | 54 var request = new Request('GET', LOCALHOST_URI); |
| 55 var newRequest = request.change(); | 55 var newRequest = request.change(); |
| 56 expect(() => newRequest.hijack((_, __) => null), | 56 expect(() => newRequest.hijack((_, __) => null), throwsStateError); |
| 57 throwsStateError); | |
| 58 }); | 57 }); |
| 59 | 58 |
| 60 test('hijacking a hijackable request throws a HijackException and calls ' | 59 test('hijacking a hijackable request throws a HijackException and calls ' |
| 61 'onHijack', () { | 60 'onHijack', () { |
| 62 var request = new Request('GET', LOCALHOST_URI, | 61 var request = new Request('GET', LOCALHOST_URI, |
| 63 onHijack: expectAsync((callback) { | 62 onHijack: expectAsync((callback) { |
| 64 var streamController = new StreamController(); | 63 var streamController = new StreamController(); |
| 65 streamController.add([1, 2, 3]); | 64 streamController.add([1, 2, 3]); |
| 66 streamController.close(); | 65 streamController.close(); |
| 67 | 66 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 | 87 |
| 89 var newRequest = request.change(); | 88 var newRequest = request.change(); |
| 90 | 89 |
| 91 expect(() => newRequest.hijack((_, __) => null), | 90 expect(() => newRequest.hijack((_, __) => null), |
| 92 throwsA(new isInstanceOf<HijackException>())); | 91 throwsA(new isInstanceOf<HijackException>())); |
| 93 | 92 |
| 94 expect(() => request.hijack((_, __) => null), throwsStateError); | 93 expect(() => request.hijack((_, __) => null), throwsStateError); |
| 95 }); | 94 }); |
| 96 }); | 95 }); |
| 97 } | 96 } |
| OLD | NEW |