@@ -22,11 +22,9 @@ void main() {
22
22
expiration: DateTime (2022 , 9 , 1 ),
23
23
),
24
24
);
25
- final testRequest = Request ('GET' , 'test' , 'test' );
26
- final unauthorizedResponse =
27
- Response (http.Response ('body' , HttpStatus .unauthorized), 'body' );
28
- final authorizedResponse =
29
- Response (http.Response ('body' , HttpStatus .accepted), 'body' );
25
+ final testRequest = Request ('GET' , Uri (host: 'test' ), Uri (host: 'test' ));
26
+ final unauthorizedResponse = Response (http.Response ('body' , HttpStatus .unauthorized), 'body' );
27
+ final authorizedResponse = Response (http.Response ('body' , HttpStatus .accepted), 'body' );
30
28
31
29
test ('only refresh on unauthorized and token' , () async {
32
30
// arrange
@@ -36,8 +34,7 @@ void main() {
36
34
final expected = {'Authorization' : 'Bearer token' };
37
35
38
36
// act
39
- final result =
40
- await authenticator.authenticate (testRequest, unauthorizedResponse);
37
+ final result = await authenticator.authenticate (testRequest, unauthorizedResponse);
41
38
42
39
// assert
43
40
verify (mockOAuthChopper.refresh ()).called (1 );
@@ -51,8 +48,7 @@ void main() {
51
48
final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
52
49
53
50
// act
54
- final result =
55
- await authenticator.authenticate (testRequest, authorizedResponse);
51
+ final result = await authenticator.authenticate (testRequest, authorizedResponse);
56
52
57
53
// assert
58
54
verifyNever (mockOAuthChopper.refresh ());
@@ -66,8 +62,7 @@ void main() {
66
62
final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
67
63
68
64
// act
69
- final result =
70
- await authenticator.authenticate (testRequest, unauthorizedResponse);
65
+ final result = await authenticator.authenticate (testRequest, unauthorizedResponse);
71
66
72
67
// assert
73
68
verifyNever (mockOAuthChopper.refresh ());
@@ -81,8 +76,7 @@ void main() {
81
76
final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
82
77
83
78
// act
84
- final result =
85
- await authenticator.authenticate (testRequest, unauthorizedResponse);
79
+ final result = await authenticator.authenticate (testRequest, unauthorizedResponse);
86
80
87
81
// assert
88
82
verify (mockOAuthChopper.refresh ()).called (1 );
@@ -97,23 +91,18 @@ void main() {
97
91
98
92
// act
99
93
// assert
100
- expect (
101
- () async =>
102
- await authenticator.authenticate (testRequest, unauthorizedResponse),
103
- throwsFormatException);
94
+ expect (() async => await authenticator.authenticate (testRequest, unauthorizedResponse), throwsFormatException);
104
95
});
105
96
106
97
test ("Exception not thrown if onError is supplied" , () async {
107
98
// arrange
108
99
FormatException ? result;
109
100
when (mockOAuthChopper.refresh ()).thenThrow (FormatException ('failed' ));
110
101
when (mockOAuthChopper.token).thenAnswer ((_) async => testToken);
111
- final authenticator = OAuthAuthenticator (
112
- mockOAuthChopper, (e, s) => result = e as FormatException );
102
+ final authenticator = OAuthAuthenticator (mockOAuthChopper, (e, s) => result = e as FormatException );
113
103
114
104
// act
115
- final responseResult =
116
- await authenticator.authenticate (testRequest, unauthorizedResponse);
105
+ final responseResult = await authenticator.authenticate (testRequest, unauthorizedResponse);
117
106
118
107
// assert
119
108
expect (result? .message, 'failed' );
0 commit comments