diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 33ff0a38..2add715d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -10,8 +10,6 @@ on: jobs: format: runs-on: ubuntu-latest - container: - image: dart:stable steps: - name: Checkout repository @@ -19,6 +17,14 @@ jobs: with: persist-credentials: true ref: ${{ github.event.pull_request.head.ref }} + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + + - name: Install dependencies + run: flutter pub get - name: Format Dart code run: dart format . @@ -29,5 +35,5 @@ jobs: - name: Add & Commit uses: EndBug/add-and-commit@v9.1.4 with: - add: lib + add: '["lib", "test"]' diff --git a/lib/query.dart b/lib/query.dart index bfdd664c..2c523869 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -120,16 +120,16 @@ class Query { Query._('updatedAfter', null, value).toString(); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => diff --git a/lib/services/account.dart b/lib/services/account.dart index 2ecd6811..01646e94 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -942,7 +942,6 @@ class Account extends Service { 'success': success, 'failure': failure, 'scopes': scopes, - 'project': client.config['project'], }; @@ -1299,7 +1298,6 @@ class Account extends Service { 'success': success, 'failure': failure, 'scopes': scopes, - 'project': client.config['project'], }; diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..c91cdb24 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -31,7 +31,6 @@ class Avatars extends Service { 'width': width, 'height': height, 'quality': quality, - 'project': client.config['project'], }; @@ -68,7 +67,6 @@ class Avatars extends Service { 'width': width, 'height': height, 'quality': quality, - 'project': client.config['project'], }; @@ -90,7 +88,6 @@ class Avatars extends Service { final Map params = { 'url': url, - 'project': client.config['project'], }; @@ -128,7 +125,6 @@ class Avatars extends Service { 'width': width, 'height': height, 'quality': quality, - 'project': client.config['project'], }; @@ -163,7 +159,6 @@ class Avatars extends Service { 'url': url, 'width': width, 'height': height, - 'project': client.config['project'], }; @@ -205,7 +200,6 @@ class Avatars extends Service { 'width': width, 'height': height, 'background': background, - 'project': client.config['project'], }; @@ -234,7 +228,6 @@ class Avatars extends Service { 'size': size, 'margin': margin, 'download': download, - 'project': client.config['project'], }; diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..e45227da 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -177,7 +177,6 @@ class Storage extends Service { final Map params = { 'token': token, - 'project': client.config['project'], }; @@ -228,7 +227,6 @@ class Storage extends Service { 'background': background, 'output': output?.value, 'token': token, - 'project': client.config['project'], }; @@ -255,7 +253,6 @@ class Storage extends Service { final Map params = { 'token': token, - 'project': client.config['project'], }; diff --git a/lib/src/client.dart b/lib/src/client.dart index 05fff190..9880d458 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,7 +27,8 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => + createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..c345e705 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -15,15 +15,14 @@ class CookieManager extends Interceptor { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..00311650 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -61,9 +61,9 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..830b6d5e 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -146,10 +146,10 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index ce0b7e95..3aab4e03 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', -); + 'Cannot create a client without dart:html or dart:io.', + ); diff --git a/test/query_test.dart b/test/query_test.dart index 915aef11..4030bc36 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -293,4 +293,3 @@ void main() { expect(query['method'], 'updatedAfter'); }); } - diff --git a/test/services/account_test.dart b/test/services/account_test.dart index ac86fdd1..475b86e7 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,1433 +40,1311 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; - - setUp(() { - client = MockClient(); - account = Account(client); - }); - - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.get( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: '', - ); - expect(response, isA()); - - }); - - test('test method updateEmail()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method listIdentities()', () async { - final Map data = { - 'total': 5, - 'identities': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listIdentities( - ); - expect(response, isA()); - - }); - - test('test method deleteIdentity()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteIdentity( - identityId: '', - ); - }); - - test('test method createJWT()', () async { - final Map data = { - 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createJWT( - ); - expect(response, isA()); - - }); - - test('test method listLogs()', () async { - final Map data = { - 'total': 5, - 'logs': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listLogs( - ); - expect(response, isA()); - - }); - - test('test method updateMFA()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - - }); - - test('test method createMfaAuthenticator()', () async { - final Map data = { - 'secret': '1', - 'uri': '1',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method createMFAAuthenticator()', () async { - final Map data = { - 'secret': '1', - 'uri': '1',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method updateMfaAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method deleteMfaAuthenticator()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method deleteMFAAuthenticator()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method createMfaChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method createMFAChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method updateMfaChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method listMfaFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMfaFactors( - ); - expect(response, isA()); - - }); - - test('test method listMFAFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + group('Account test', () { + late MockClient client; + late Account account; + setUp(() { + client = MockClient(); + account = Account(client); + }); - final response = await account.listMFAFactors( - ); - expect(response, isA()); - - }); - - test('test method getMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.get(); + expect(response, isA()); + }); + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.create( + userId: '', + email: 'email@example.com', + password: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateEmail()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [], + }; - final response = await account.getMfaRecoveryCodes( - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.listIdentities(); + expect(response, isA()); + }); - test('test method getMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + test('test method deleteIdentity()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteIdentity( + identityId: '', + ); + }); + test('test method createJWT()', () async { + final Map data = { + 'jwt': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + }; - final response = await account.getMFARecoveryCodes( - ); - expect(response, isA()); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createJWT(); + expect(response, isA()); + }); - test('test method createMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listLogs(); + expect(response, isA()); + }); + test('test method updateMFA()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); + }); - final response = await account.createMfaRecoveryCodes( - ); - expect(response, isA()); + test('test method createMfaAuthenticator()', () async { + final Map data = { + 'secret': '1', + 'uri': '1', + }; - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '1', + 'uri': '1', + }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); - final response = await account.createMFARecoveryCodes( - ); - expect(response, isA()); + test('test method updateMfaAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); - }); + test('test method updateMFAAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); - test('test method updateMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + test('test method deleteMfaAuthenticator()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + test('test method deleteMFAAuthenticator()', () async { + final data = ''; - final response = await account.updateMfaRecoveryCodes( - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - test('test method updateMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + test('test method createMfaChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); + test('test method createMFAChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMfaChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); + test('test method updateMFAChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); - final response = await account.updateMFARecoveryCodes( - ); - expect(response, isA()); + test('test method listMfaFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + final response = await account.listMfaFactors(); + expect(response, isA()); + }); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.listMFAFactors(); + expect(response, isA()); + }); - final response = await account.updateName( - name: '', - ); - expect(response, isA()); + test('test method getMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updatePassword()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.getMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.updatePassword( - password: '', - ); - expect(response, isA()); - - }); - - test('test method updatePhone()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method getPrefs()', () async { - final Map data = {}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getPrefs( - ); - expect(response, isA()); - - }); - - test('test method updatePrefs()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - - }); - - test('test method createRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method updateRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateRecovery( - userId: '', - secret: '', - password: '', - ); - expect(response, isA()); - - }); - - test('test method listSessions()', () async { - final Map data = { - 'total': 5, - 'sessions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listSessions( - ); - expect(response, isA()); - - }); - - test('test method deleteSessions()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSessions( - ); - }); - - test('test method createAnonymousSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createAnonymousSession( - ); - expect(response, isA()); - - }); - - test('test method createEmailPasswordSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateMagicURLSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createOAuth2Session()', () async { - - when(client.webAuth( - Uri(), - )).thenAnswer((_) async => 'done'); - - - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - }); - - test('test method updatePhoneSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method getSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSession()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSession( - sessionId: '', - ); - }); - - test('test method updateStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateStatus( - ); - expect(response, isA()); - - }); - - test('test method createPushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - - }); - - test('test method updatePushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; - + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.getMFARecoveryCodes(); + expect(response, isA()); + }); + test('test method createMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createMfaRecoveryCodes(); + expect(response, isA()); + }); - test('test method deletePushTarget()', () async { - final data = ''; + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createMFARecoveryCodes(); + expect(response, isA()); + }); - final response = await account.deletePushTarget( - targetId: '', - ); - }); + test('test method updateMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - test('test method createEmailToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.updateMfaRecoveryCodes(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + final response = await account.updateMFARecoveryCodes(); + expect(response, isA()); + }); - }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + }); - test('test method createMagicURLToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updatePassword()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePassword( + password: '', + ); + expect(response, isA()); + }); + test('test method updatePhone()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method getPrefs()', () async { + final Map data = {}; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + final response = await account.getPrefs(); + expect(response, isA()); + }); - }); + test('test method updatePrefs()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + }); - test('test method createOAuth2Token()', () async { + test('test method createRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.webAuth( - Uri(), - )).thenAnswer((_) async => 'done'); + test('test method updateRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: '', + ); + expect(response, isA()); + }); + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [], + }; - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createPhoneToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + final response = await account.listSessions(); + expect(response, isA()); + }); + test('test method deleteSessions()', () async { + final data = ''; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSessions(); + }); - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); + test('test method createAnonymousSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createAnonymousSession(); + expect(response, isA()); + }); - }); + test('test method createEmailPasswordSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - test('test method createVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateMagicURLSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); + test('test method createOAuth2Session()', () async { + when(client.webAuth( + Uri(), + )).thenAnswer((_) async => 'done'); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + }); + test('test method updatePhoneSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method createSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method getSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + }); - test('test method updateVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + }); + test('test method deleteSession()', () async { + final data = ''; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSession( + sessionId: '', + ); + }); - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateStatus(); + expect(response, isA()); + }); - }); + test('test method createPushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - test('test method createPhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updatePushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); + test('test method deletePushTarget()', () async { + final data = ''; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deletePushTarget( + targetId: '', + ); + }); - final response = await account.createPhoneVerification( - ); - expect(response, isA()); + test('test method createEmailToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - }); + test('test method createMagicURLToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - test('test method updatePhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createOAuth2Token()', () async { + when(client.webAuth( + Uri(), + )).thenAnswer((_) async => 'done'); + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createPhoneToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + }); + test('test method createVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createPhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneVerification(); + expect(response, isA()); + }); + test('test method updatePhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 0cd4b70d..01abe69c 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,116 +40,110 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; - - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); - - test('test method getBrowser()', () async {final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - - }); - - test('test method getCreditCard()', () async {final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - - }); + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - test('test method getFavicon()', () async {final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); - test('test method getFlag()', () async {final Uint8List data = Uint8List.fromList([]); + test('test method getBrowser()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); + }); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); + test('test method getCreditCard()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getImage()', () async {final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFavicon()', () async { + final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + }); - }); + test('test method getFlag()', () async { + final Uint8List data = Uint8List.fromList([]); - test('test method getInitials()', () async {final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); + }); + test('test method getImage()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getInitials( - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + }); - test('test method getQR()', () async {final Uint8List data = Uint8List.fromList([]); + test('test method getInitials()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getInitials(); + expect(response, isA()); + }); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); + test('test method getQR()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index aeceecf2..fb78fbb0 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,207 +40,194 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; - - setUp(() { - client = MockClient(); - databases = Databases(client); - }); - - test('test method listDocuments()', () async { - final Map data = { - 'total': 5, - 'documents': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - - }); - - test('test method createDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); + group('Databases test', () { + late MockClient client; + late Databases databases; - }); - - test('test method updateDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + setUp(() { + client = MockClient(); + databases = Databases(client); + }); + test('test method listDocuments()', () async { + final Map data = { + 'total': 5, + 'documents': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteDocument()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - + test('test method createDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + }); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); - - test('test method decrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method getDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); + test('test method upsertDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + }); - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + test('test method updateDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - }); - - test('test method incrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteDocument()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); - }); + test('test method decrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + }); + test('test method incrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 69b86785..c6e50a50 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,104 +40,100 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; - - setUp(() { - client = MockClient(); - functions = Functions(client); - }); - - test('test method listExecutions()', () async { - final Map data = { - 'total': 5, - 'executions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method createExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method getExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + group('Functions test', () { + late MockClient client; + late Functions functions; + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listExecutions()', () async { + final Map data = { + 'total': 5, + 'executions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + }); + test('test method getExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 1c096784..84b7de1c 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,45 +40,45 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; - - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); - - test('test method query()', () async { - final data = ''; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + group('Graphql test', () { + late MockClient client; + late Graphql graphql; + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - final response = await graphql.query( - query: {}, - ); - }); + test('test method query()', () async { + final data = ''; - test('test method mutation()', () async { - final data = ''; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.query( + query: {}, + ); + }); + test('test method mutation()', () async { + final data = ''; - final response = await graphql.mutation( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); }); -} \ No newline at end of file + }); +} diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index ccdcb5d3..f9f6489d 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,160 +40,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; - - setUp(() { - client = MockClient(); - locale = Locale(client); - }); - - test('test method get()', () async { - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.get( - ); - expect(response, isA()); - - }); - - test('test method listCodes()', () async { - final Map data = { - 'total': 5, - 'localeCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCodes( - ); - expect(response, isA()); - - }); - - test('test method listContinents()', () async { - final Map data = { - 'total': 5, - 'continents': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listContinents( - ); - expect(response, isA()); + group('Locale test', () { + late MockClient client; + late Locale locale; - }); - - test('test method listCountries()', () async { - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountries( - ); - expect(response, isA()); - - }); - - test('test method listCountriesEU()', () async { - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); + test('test method get()', () async { + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await locale.get(); + expect(response, isA()); + }); - final response = await locale.listCountriesEU( - ); - expect(response, isA()); + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listCountriesPhones()', () async { - final Map data = { - 'total': 5, - 'phones': [],}; + final response = await locale.listCodes(); + expect(response, isA()); + }); + test('test method listContinents()', () async { + final Map data = { + 'total': 5, + 'continents': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listContinents(); + expect(response, isA()); + }); - final response = await locale.listCountriesPhones( - ); - expect(response, isA()); + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listCurrencies()', () async { - final Map data = { - 'total': 5, - 'currencies': [],}; + final response = await locale.listCountries(); + expect(response, isA()); + }); + test('test method listCountriesEU()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCountriesEU(); + expect(response, isA()); + }); - final response = await locale.listCurrencies( - ); - expect(response, isA()); + test('test method listCountriesPhones()', () async { + final Map data = { + 'total': 5, + 'phones': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listLanguages()', () async { - final Map data = { - 'total': 5, - 'languages': [],}; + final response = await locale.listCountriesPhones(); + expect(response, isA()); + }); + test('test method listCurrencies()', () async { + final Map data = { + 'total': 5, + 'currencies': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCurrencies(); + expect(response, isA()); + }); - final response = await locale.listLanguages( - ); - expect(response, isA()); + test('test method listLanguages()', () async { + final Map data = { + 'total': 5, + 'languages': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listLanguages(); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index ddb93457..0c938eff 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,69 +40,68 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; - - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); - - test('test method createSubscriber()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - + group('Messaging test', () { + late MockClient client; + late Messaging messaging; - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSubscriber()', () async { - final data = ''; + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createSubscriber()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + }); + test('test method deleteSubscriber()', () async { + final data = ''; - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); }); -} \ No newline at end of file + }); +} diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 9d250109..19b0d334 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,185 +40,175 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; - - setUp(() { - client = MockClient(); - storage = Storage(client); - }); - - test('test method listFiles()', () async { - final Map data = { - 'total': 5, - 'files': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - - }); - - test('test method createFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'chunksTotal': 17890, - 'chunksUploaded': 17890,}; - - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - - }); - - test('test method getFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'chunksTotal': 17890, - 'chunksUploaded': 17890,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method updateFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'chunksTotal': 17890, - 'chunksUploaded': 17890,}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - + group('Storage test', () { + late MockClient client; + late Storage storage; - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteFile()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + test('test method listFiles()', () async { + final Map data = { + 'total': 5, + 'files': [], + }; - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getFileDownload()', () async {final Uint8List data = Uint8List.fromList([]); + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method createFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + }; + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + }); + test('test method getFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method updateFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - }); + test('test method deleteFile()', () async { + final data = ''; - test('test method getFilePreview()', () async {final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + test('test method getFileDownload()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - test('test method getFileView()', () async {final Uint8List data = Uint8List.fromList([]); + test('test method getFilePreview()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method getFileView()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 9b11eb45..59098320 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,206 +40,193 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; - - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); - - test('test method listRows()', () async { - final Map data = { - 'total': 5, - 'rows': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - - }); - - test('test method createRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method updateRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteRow()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); - - test('test method decrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method listRows()', () async { + final Map data = { + 'total': 5, + 'rows': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + }); + test('test method createRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - + test('test method getRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + test('test method upsertRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - }); + test('test method updateRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - test('test method incrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteRow()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); - }); + test('test method decrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + }); + test('test method incrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index c2e5ff04..9a2eb930 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,305 +40,280 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; - - setUp(() { - client = MockClient(); - teams = Teams(client); - }); - - test('test method list()', () async { - final Map data = { - 'total': 5, - 'teams': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.list( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - + group('Teams test', () { + late MockClient client; + late Teams teams; - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method delete()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.delete( - teamId: '', - ); - }); - - test('test method listMemberships()', () async { - final Map data = { - 'total': 5, - 'memberships': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - test('test method createMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'roles': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method getMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'roles': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'roles': [],}; + final response = await teams.list(); + expect(response, isA()); + }); + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); + }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method deleteMembership()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); - - test('test method updateMembershipStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'roles': [],}; + test('test method delete()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await teams.delete( + teamId: '', + ); + }); + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [], + }; - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + }); - test('test method getPrefs()', () async { - final Map data = {}; + test('test method createMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + }); + test('test method getMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + }); + test('test method deleteMembership()', () async { + final data = ''; - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); - test('test method updatePrefs()', () async { - final Map data = {}; + test('test method updateMembershipStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = {}; - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); }); -} \ No newline at end of file + }); +} diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 15e85f5a..261daa46 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 87a3ca3c..3da36624 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index 3b842e6c..e58fa5b5 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 49b1e22c..3bcbb488 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index dd7fa8c3..b2084927 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,16 +8,18 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index c7d9cdbf..8c131568 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index ae58b57e..d080569c 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index 8de695b0..e71dcae1 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index d5242a4e..85e559f5 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 869f5db6..6df5c584 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index bc66ab7b..d5404a7f 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index 09da675c..d7410db8 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 29890008..00e046c7 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index f1a5b3cc..217d37e8 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index be617cc6..fd46464b 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, 1); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, 1); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index fe74af58..a3305e55 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index ed6fb8e2..e5682521 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -27,23 +27,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, 'http'); - expect(result.status, 'processing'); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, 'http'); + expect(result.status, 'processing'); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index d8e6c95c..8e02f65e 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 08da5e9a..e6d6dae5 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -21,17 +21,17 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 489891d4..9252b469 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 65f562a7..8c35afec 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 708c8c60..525af4ea 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index e616a956..93376af1 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,13 +5,15 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 94c1e33f..a07c0b5f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index d4087d5e..4a6c96c1 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index b6de5137..65b44ad1 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index f0fcdbce..88cf157b 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 72102045..49cb1fc9 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 84c560c8..b07ca8ee 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index 7724b875..b328ad58 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -31,27 +31,27 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index bb1f0946..4f30c48e 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index 32ba0f4e..2fee0d28 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -23,19 +23,19 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 9410baa3..5d3febca 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index ed6467d3..64cc55e4 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index fa097a49..500913c8 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index dcee3fcb..fb964947 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '1'); - expect(result.uri, '1'); - }); + expect(result.secret, '1'); + expect(result.uri, '1'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index 6ca46a63..bf22a5c7 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index d0e5333b..f70db0e3 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index acde349c..9db30b03 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,7 +10,6 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); - }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index d4900dd4..12693926 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 4c525e1b..fed01ffa 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, 1); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, 1); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index eaab249e..708e0583 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 0177e477..689e6048 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 94c6a502..7445514c 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index a49f3def..49f1e75e 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index a19b667d..fe2f4a85 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index 43b2e45c..f652f2c1 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 7ee4b268..8f0957c9 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index c058ea26..77c7dd97 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); }