1+ // ignore so the test is easier to read.
2+ // ignore_for_file: avoid_redundant_argument_values
3+
14import 'dart:io' ;
25
36import 'package:chopper/chopper.dart' ;
@@ -28,7 +31,7 @@ void main() {
2831
2932 test ('only refresh on unauthorized and token' , () async {
3033 // arrange
31- when (() => mockOAuthChopper.refresh () ).thenAnswer ((_) async => testToken);
34+ when (mockOAuthChopper.refresh).thenAnswer ((_) async => testToken);
3235 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testToken);
3336 final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
3437 final expected = {'Authorization' : 'Bearer token' };
@@ -38,13 +41,13 @@ void main() {
3841 await authenticator.authenticate (testRequest, unauthorizedResponse);
3942
4043 // assert
41- verify (() => mockOAuthChopper.refresh () ).called (1 );
44+ verify (mockOAuthChopper.refresh).called (1 );
4245 expect (result? .headers, expected);
4346 });
4447
4548 test ("Don't refresh on authorized" , () async {
4649 // arrange
47- when (() => mockOAuthChopper.refresh () ).thenAnswer ((_) async => testToken);
50+ when (mockOAuthChopper.refresh).thenAnswer ((_) async => testToken);
4851 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testToken);
4952 final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
5053
@@ -53,13 +56,13 @@ void main() {
5356 await authenticator.authenticate (testRequest, authorizedResponse);
5457
5558 // assert
56- verifyNever (() => mockOAuthChopper.refresh () );
59+ verifyNever (mockOAuthChopper.refresh);
5760 expect (result, null );
5861 });
5962
6063 test ("Don't refresh on token not available" , () async {
6164 // arrange
62- when (() => mockOAuthChopper.refresh () ).thenAnswer ((_) async => testToken);
65+ when (mockOAuthChopper.refresh).thenAnswer ((_) async => testToken);
6366 when (() => mockOAuthChopper.token).thenAnswer ((_) async => null );
6467 final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
6568
@@ -68,13 +71,13 @@ void main() {
6871 await authenticator.authenticate (testRequest, unauthorizedResponse);
6972
7073 // assert
71- verifyNever (() => mockOAuthChopper.refresh () );
74+ verifyNever (mockOAuthChopper.refresh);
7275 expect (result, null );
7376 });
7477
7578 test ("Don't add headers on failed refresh" , () async {
7679 // arrange
77- when (() => mockOAuthChopper.refresh () ).thenAnswer ((_) async => null );
80+ when (mockOAuthChopper.refresh).thenAnswer ((_) async => null );
7881 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testToken);
7982 final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
8083
@@ -83,31 +86,34 @@ void main() {
8386 await authenticator.authenticate (testRequest, unauthorizedResponse);
8487
8588 // assert
86- verify (() => mockOAuthChopper.refresh () ).called (1 );
89+ verify (mockOAuthChopper.refresh).called (1 );
8790 expect (result, null );
8891 });
8992
90- test (" Exception thrown if onError is null" , () async {
93+ test (' Exception thrown if onError is null' , () async {
9194 // arrange
92- when (() => mockOAuthChopper.refresh ()) .thenThrow (FormatException ('failed' ));
95+ when (mockOAuthChopper.refresh) .thenThrow (const FormatException ('failed' ));
9396 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testToken);
9497 final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
9598
9699 // act
97100 // assert
98101 expect (
99- () async =>
100- await authenticator.authenticate (testRequest, unauthorizedResponse),
101- throwsFormatException);
102+ () async =>
103+ await authenticator.authenticate (testRequest, unauthorizedResponse),
104+ throwsFormatException,
105+ );
102106 });
103107
104- test (" Exception not thrown if onError is supplied" , () async {
108+ test (' Exception not thrown if onError is supplied' , () async {
105109 // arrange
106110 FormatException ? result;
107- when (() => mockOAuthChopper.refresh ()) .thenThrow (FormatException ('failed' ));
111+ when (mockOAuthChopper.refresh) .thenThrow (const FormatException ('failed' ));
108112 when (() => mockOAuthChopper.token).thenAnswer ((_) async => testToken);
109113 final authenticator = OAuthAuthenticator (
110- mockOAuthChopper, (e, s) => result = e as FormatException );
114+ mockOAuthChopper,
115+ (e, s) => result = e as FormatException ,
116+ );
111117
112118 // act
113119 final responseResult =
0 commit comments