Skip to content

Commit 40700c7

Browse files
committed
account tests working
1 parent 9a5ec5e commit 40700c7

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

templates/flutter/test/services/service_test.dart.twig

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:appwrite/appwrite.dart';
99

1010
class MockClient extends Mock implements Client {
1111
Map<String, String> config = {'project': 'testproject'};
12-
12+
String endPoint = 'https://localhost/v1';
1313
@override
1414
Future<Response> call(
1515
HttpMethod? method, {
@@ -18,10 +18,19 @@ class MockClient extends Mock implements Client {
1818
Map<String, dynamic> params = const {},
1919
ResponseType? responseType,
2020
}) async {
21-
super.noSuchMethod(Invocation.method(#call, [method]));
2221
return super.noSuchMethod(Invocation.method(#call, [method]),
2322
returnValue: Response());
2423
}
24+
25+
@override
26+
Future webAuth(
27+
Uri? url,
28+
{
29+
String? callbackUrlScheme,
30+
}
31+
) async {
32+
return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done');
33+
}
2534
}
2635

2736
void main() {
@@ -44,17 +53,23 @@ void main() {
4453
{%~ if method.responseModel and method.responseModel != 'any' ~%}
4554
final Map<String, dynamic> data = {
4655
{%- for definition in spec.definitions ~%}{%~ if definition.name == method.responseModel -%}{%~ for property in definition.properties | filter((param) => param.required) ~%}
47-
'{{property.name | escapeKeyword | escapeDollarSign}}': {% if property.type == 'object' %}{}{% elseif property.type == 'array' %}[]{% elseif property.type == 'string' %}'{{property.example}}'{% else %}{{property.example}}{% endif %},{%~ endfor ~%}{% set break = true %}{%- else -%}{% set continue = true %}{%- endif -%}{%~ endfor -%}
56+
'{{property.name | escapeKeyword | escapeDollarSign}}': {% if property.type == 'object' %}<String, dynamic>{}{% elseif property.type == 'array' %}[]{% elseif property.type == 'string' %}'{{property.example}}'{% elseif property.type == 'boolean' %}true{% else %}{{property.example}}{% endif %},{%~ endfor ~%}{% set break = true %}{%- else -%}{% set continue = true %}{%- endif -%}{%~ endfor -%}
4857

4958
};
5059
{%~ else ~%}
51-
final data = null;
60+
final data = '';
5261
{%- endif -%}
5362
{% endif %}
5463

64+
{%~ if method.type == 'webAuth' ~%}
65+
when(client.webAuth(
66+
Uri(),
67+
)).thenAnswer((_) async => 'done');
68+
{%~ else ~%}
5569
when(client.call(
5670
HttpMethod.{{method.method | caseLower}},
5771
)).thenAnswer((_) async => Response(data: data));
72+
{%~ endif ~%}
5873

5974
final response = await {{service.name | caseCamel}}.{{method.name | caseCamel}}({%~ for parameter in method.parameters.all | filter((param) => param.required) ~%}
6075
{{parameter.name | caseCamel}}: {% if parameter.type == 'object' %}{}{% else %}'{{parameter.example}}'{%~ endif ~%},{%~ endfor ~%}

0 commit comments

Comments
 (0)