Files

85 lines
2.1 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:appwrite/models.dart' as models;
import 'package:appwrite/enums.dart' as enums;
import 'package:appwrite/src/enums.dart';
import 'package:appwrite/src/response.dart';
import 'dart:typed_data';
import 'package:appwrite/appwrite.dart';
class MockClient extends Mock implements Client {
Map<String, String> config = {'project': 'testproject'};
String endPoint = 'https://localhost/v1';
@override
Future<Response> call(
HttpMethod? method, {
String path = '',
Map<String, String> headers = const {},
Map<String, dynamic> params = const {},
ResponseType? responseType,
}) async {
return super.noSuchMethod(Invocation.method(#call, [method]),
returnValue: Response());
}
@override
Future webAuth(
Uri? url, {
String? callbackUrlScheme,
}) async {
return super
.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done');
}
@override
Future<Response> chunkedUpload({
String? path,
Map<String, dynamic>? params,
String? paramName,
String? idParamName,
Map<String, String>? headers,
Function(UploadProgress)? onProgress,
}) async {
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));
final response = await graphql.query(
query: {},
);
});
test('test method mutation()', () async {
final data = '';
when(client.call(
HttpMethod.post,
)).thenAnswer((_) async => Response(data: data));
final response = await graphql.mutation(
query: {},
);
});
});
}