Skip to content

Commit 85fa20d

Browse files
committed
feat: add tests for ErrorEnums
- new tests for Dart and Flutter Signed-off-by: Jay <jaykumar20march@gmail.com>
1 parent a07a4b6 commit 85fa20d

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/SDK/Language/Flutter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ public function getFiles(): array
330330
'destination' => '.travis.yml',
331331
'template' => 'flutter/.travis.yml.twig',
332332
],
333+
[
334+
'scope' => 'default',
335+
'destination' => '/test/src/exception_test.dart',
336+
'template' => 'flutter/test/src/exception_test.dart.twig',
337+
],
333338
];
334339
}
335340
}

templates/dart/test/src/exception_test.dart.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ void main() {
1818
expect(exception3.toString(), equals('{{spec.title | caseUcfirst}}Exception: ValidationError, Invalid request (400)'));
1919
});
2020
});
21+
22+
group('ErrorType Enum Test', () {
23+
{% for key, value in testData.enumData %}
24+
test('ErrorType.{{ key }} should have correct value', () {
25+
expect(ErrorType.{{ key }}.toString(), equals('ErrorType.{{ value }}'));
26+
});
27+
{% endfor %}
28+
});
2129
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
enum ErrorType {
2+
{% for error in spec.definitions.appwriteException.error_types %}
3+
/// {{ error.description }}
4+
{{ error.type|title|replace({'_': ''}) }},
5+
{% endfor %}
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import 'package:{{language.params.packageName}}/src/exception.dart';
2+
{% if 'dart' in language.params.packageName %}
3+
import 'package:test/test.dart';
4+
{% else %}
5+
import 'package:flutter_test/flutter_test.dart';
6+
{% endif %}
7+
8+
void main() {
9+
group('ErrorType Enum Test', () {
10+
{% for key, value in testData.enumData %}
11+
test('ErrorType.{{ key }} should have correct value', () {
12+
expect(ErrorType.{{ key }}.toString(), equals('ErrorType.{{ value }}'));
13+
});
14+
{% endfor %}
15+
});
16+
}

0 commit comments

Comments
 (0)