@@ -13,15 +13,16 @@ import 'package:test/test.dart';
1313
1414class MockOAuthChopper extends Mock implements OAuthChopper {}
1515
16- class MockChain extends Mock implements Chain {}
16+ class MockChain extends Mock implements Chain < dynamic > {}
1717
1818void main () {
1919 final testRequest = Request (
2020 'GET' ,
2121 Uri (host: 'test' ),
2222 Uri (host: 'test' ),
2323 );
24- final authorizedResponse = Response (http.Response ('body' , HttpStatus .accepted), 'body' );
24+ final authorizedResponse =
25+ Response (http.Response ('body' , HttpStatus .accepted), 'body' );
2526 registerFallbackValue (testRequest);
2627 registerFallbackValue (authorizedResponse);
2728
@@ -46,7 +47,8 @@ void main() {
4647 );
4748
4849 when (() => mockChain.request).thenReturn (testRequest);
49- when (() => mockChain.proceed (any ())).thenAnswer ((_) async => authorizedResponse);
50+ when (() => mockChain.proceed (any ()))
51+ .thenAnswer ((_) async => authorizedResponse);
5052
5153 test ('HeaderInterceptor adds available token to headers' , () async {
5254 // arrange
@@ -58,10 +60,12 @@ void main() {
5860 await interceptor.intercept (mockChain);
5961
6062 // assert
61- verify (() => mockChain.proceed (testRequest.copyWith (headers: expected))).called (1 );
63+ verify (() => mockChain.proceed (testRequest.copyWith (headers: expected)))
64+ .called (1 );
6265 });
6366
64- test ('HeaderInterceptor does not add IDToken when available to headers' , () async {
67+ test ('HeaderInterceptor does not add IDToken when available to headers' ,
68+ () async {
6569 // arrange
6670 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testIDtoken);
6771 final interceptor = OAuthInterceptor (mockOAuthChopper, null );
@@ -71,7 +75,8 @@ void main() {
7175 await interceptor.intercept (mockChain);
7276
7377 // assert
74- verify (() => mockChain.proceed (testRequest.copyWith (headers: expected))).called (1 );
78+ verify (() => mockChain.proceed (testRequest.copyWith (headers: expected)))
79+ .called (1 );
7580 });
7681
7782 test ('HeaderInterceptor adds no token to headers' , () async {
@@ -84,7 +89,8 @@ void main() {
8489 await interceptor.intercept (mockChain);
8590
8691 // assert
87- verify (() => mockChain.proceed (testRequest.copyWith (headers: expected))).called (1 );
92+ verify (() => mockChain.proceed (testRequest.copyWith (headers: expected)))
93+ .called (1 );
8894 });
8995 });
9096
@@ -98,10 +104,12 @@ void main() {
98104 expiration: DateTime (2022 , 9 , 1 ),
99105 ),
100106 );
101- final unauthorizedResponse = Response (http.Response ('body' , HttpStatus .unauthorized), 'body' );
107+ final unauthorizedResponse =
108+ Response (http.Response ('body' , HttpStatus .unauthorized), 'body' );
102109 setUp (() {
103110 when (() => mockChain.request).thenReturn (testRequest);
104- when (() => mockChain.proceed (any ())).thenAnswer ((_) async => unauthorizedResponse);
111+ when (() => mockChain.proceed (any ()))
112+ .thenAnswer ((_) async => unauthorizedResponse);
105113 });
106114
107115 test ('only refresh on unauthorized and token' , () async {
@@ -116,12 +124,14 @@ void main() {
116124
117125 // assert
118126 verify (mockOAuthChopper.refresh).called (1 );
119- verify (() => mockChain.proceed (testRequest.copyWith (headers: expected))).called (2 );
127+ verify (() => mockChain.proceed (testRequest.copyWith (headers: expected)))
128+ .called (2 );
120129 });
121130
122131 test ("Don't refresh on authorized" , () async {
123132 // arrange
124- when (() => mockChain.proceed (any ())).thenAnswer ((_) async => authorizedResponse);
133+ when (() => mockChain.proceed (any ()))
134+ .thenAnswer ((_) async => authorizedResponse);
125135 when (mockOAuthChopper.refresh).thenAnswer ((_) async => testToken);
126136 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testToken);
127137 final interceptor = OAuthInterceptor (mockOAuthChopper, null );
@@ -186,7 +196,7 @@ void main() {
186196 );
187197
188198 // act
189- await interceptor.intercept (mockChain);
199+ await interceptor.intercept (mockChain);
190200
191201 // assert
192202 expect (result? .message, 'failed' );
0 commit comments