@@ -9,7 +9,7 @@ import 'package:appwrite/appwrite.dart';
9
9
10
10
class MockClient extends Mock implements Client {
11
11
Map<String , String > config = {'project': 'testproject'};
12
-
12
+ String endPoint = 'https://localhost/v1';
13
13
@override
14
14
Future<Response > call(
15
15
HttpMethod? method, {
@@ -18,10 +18,19 @@ class MockClient extends Mock implements Client {
18
18
Map<String , dynamic > params = const {},
19
19
ResponseType? responseType,
20
20
}) async {
21
- super.noSuchMethod(Invocation.method(#call, [method]));
22
21
return super.noSuchMethod(Invocation.method(#call, [method]),
23
22
returnValue: Response());
24
23
}
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
+ }
25
34
}
26
35
27
36
void main() {
@@ -44,17 +53,23 @@ void main() {
44
53
{%~ if method .responseModel and method .responseModel != ' any' ~%}
45
54
final Map<String , dynamic > data = {
46
55
{%- 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 -%}
48
57
49
58
};
50
59
{%~ else ~%}
51
- final data = null ;
60
+ final data = '' ;
52
61
{%- endif -%}
53
62
{% endif %}
54
63
64
+ {%~ if method .type == ' webAuth' ~%}
65
+ when(client.webAuth(
66
+ Uri(),
67
+ )).thenAnswer((_) async => 'done');
68
+ {%~ else ~%}
55
69
when(client.call(
56
70
HttpMethod.{{method .method | caseLower }},
57
71
)).thenAnswer((_) async => Response(data: data));
72
+ {%~ endif ~%}
58
73
59
74
final response = await {{service .name | caseCamel }}.{{method .name | caseCamel }}({%~ for parameter in method .parameters .all | filter((param ) => param .required ) ~%}
60
75
{{parameter .name | caseCamel }}: {% if parameter .type == ' object' %}{}{% else %}'{{parameter .example }}'{%~ endif ~%},{%~ endfor ~%}
0 commit comments