Chromium Code Reviews| Index: pkg/oauth2/test/authorization_code_grant_test.dart |
| diff --git a/pkg/oauth2/test/authorization_code_grant_test.dart b/pkg/oauth2/test/authorization_code_grant_test.dart |
| index 85c54e758f88e6d46c9e35134078369929847900..1740b8a684378fd924473ed873a2b3a309ada254 100644 |
| --- a/pkg/oauth2/test/authorization_code_grant_test.dart |
| +++ b/pkg/oauth2/test/authorization_code_grant_test.dart |
| @@ -29,12 +29,6 @@ void createGrant() { |
| httpClient: client); |
| } |
| -void expectFutureThrows(future, predicate) { |
| - future.catchError(expectAsync1((error) { |
| - expect(predicate(error), isTrue); |
| - })); |
| -} |
| - |
| void main() { |
| group('.getAuthorizationUrl', () { |
| setUp(createGrant); |
| @@ -96,46 +90,46 @@ void main() { |
| setUp(createGrant); |
| test("can't be called before .getAuthorizationUrl", () { |
| - expectFutureThrows(grant.handleAuthorizationResponse({}), |
| - (e) => e is StateError); |
| + expect(grant.handleAuthorizationResponse({}), |
| + throwsStateError); |
|
nweiz
2014/03/05 22:38:08
Indent this correctly.
kevmoo
2014/03/06 00:01:42
Done.
|
| }); |
| test("can't be called twice", () { |
| grant.getAuthorizationUrl(redirectUrl); |
| - expectFutureThrows( |
| + expect( |
| grant.handleAuthorizationResponse({'code': 'auth code'}), |
| - (e) => e is FormatException); |
| - expectFutureThrows( |
| + throwsFormatException); |
| + expect( |
| grant.handleAuthorizationResponse({'code': 'auth code'}), |
| - (e) => e is StateError); |
| + throwsStateError); |
| }); |
| test('must have a state parameter if the authorization URL did', () { |
| grant.getAuthorizationUrl(redirectUrl, state: 'state'); |
| - expectFutureThrows( |
| + expect( |
| grant.handleAuthorizationResponse({'code': 'auth code'}), |
| - (e) => e is FormatException); |
| + throwsFormatException); |
| }); |
| test('must have the same state parameter the authorization URL did', () { |
| grant.getAuthorizationUrl(redirectUrl, state: 'state'); |
| - expectFutureThrows(grant.handleAuthorizationResponse({ |
| + expect(grant.handleAuthorizationResponse({ |
| 'code': 'auth code', |
| 'state': 'other state' |
| - }), (e) => e is FormatException); |
| + }), throwsFormatException); |
| }); |
| test('must have a code parameter', () { |
| grant.getAuthorizationUrl(redirectUrl); |
| - expectFutureThrows(grant.handleAuthorizationResponse({}), |
| - (e) => e is FormatException); |
| + expect(grant.handleAuthorizationResponse({}), |
| + throwsFormatException); |
|
nweiz
2014/03/05 22:38:08
Indent this correctly.
kevmoo
2014/03/06 00:01:42
Done.
|
| }); |
| test('with an error parameter throws an AuthorizationException', () { |
| grant.getAuthorizationUrl(redirectUrl); |
| - expectFutureThrows( |
| + expect( |
| grant.handleAuthorizationResponse({'error': 'invalid_request'}), |
| - (e) => e is oauth2.AuthorizationException); |
| + throwsA((e) => e is oauth2.AuthorizationException)); |
| }); |
| test('sends an authorization code request', () { |
| @@ -157,10 +151,10 @@ void main() { |
| }), 200, headers: {'content-type': 'application/json'})); |
| }); |
| - grant.handleAuthorizationResponse({'code': 'auth code'}) |
| - .then(expectAsync1((client) { |
| + return grant.handleAuthorizationResponse({'code': 'auth code'}) |
| + .then((client) { |
| expect(client.credentials.accessToken, equals('access token')); |
| - })); |
| + }); |
|
nweiz
2014/03/05 22:38:08
These days I'd write this as
expect(grant.han
kevmoo
2014/03/06 00:01:42
Done.
|
| }); |
| }); |
| @@ -168,18 +162,18 @@ void main() { |
| setUp(createGrant); |
| test("can't be called before .getAuthorizationUrl", () { |
| - expectFutureThrows( |
| + expect( |
| grant.handleAuthorizationCode('auth code'), |
| - (e) => e is StateError); |
| + throwsStateError); |
| }); |
| test("can't be called twice", () { |
| grant.getAuthorizationUrl(redirectUrl); |
| - expectFutureThrows( |
| + expect( |
| grant.handleAuthorizationCode('auth code'), |
| - (e) => e is FormatException); |
| - expectFutureThrows(grant.handleAuthorizationCode('auth code'), |
| - (e) => e is StateError); |
| + throwsFormatException); |
| + expect(grant.handleAuthorizationCode('auth code'), |
| + throwsStateError); |
|
nweiz
2014/03/05 22:38:08
Indent this correctly.
kevmoo
2014/03/06 00:01:42
Done.
|
| }); |
| test('sends an authorization code request', () { |