Skip to content

Commit

Permalink
Expanded unit tests to support 'expose_http_client'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenvervaeke committed Aug 24, 2022
1 parent ea9f95f commit 37be963
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/generator_tests/additions_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void main() {

expect(result, contains("part 'swagger.fileName.swagger.chopper.dart';"));
expect(result, contains("part 'swagger.fileName.swagger.g.dart';"));
expect(
result, isNot(contains("import 'package:http/http.dart' as http;")));
});

test('Should generate correct imports', () {
Expand All @@ -27,6 +29,13 @@ void main() {
contains("import 'swagger.fileName.enums.swagger.dart' as enums;"));
});

test('Should generate correct imports', () {
final result = generator.generateImportsContent(
'swagger.fileName', true, false, true, true, false);

expect(result, contains("import 'package:http/http.dart' as http;"));
});

test('Should generate indexes file', () {
final result = generator.generateIndexes(<String>[
'someFile.dart',
Expand Down
4 changes: 3 additions & 1 deletion test/generator_tests/requests_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void main() {
swaggerRoot: root,
className: 'CarsService',
fileName: 'cars_service',
exposeHttpClient: false,
exposeHttpClient: true,
);

expect(result2, contains('Future<chopper.Response<CarModel>>'));
Expand All @@ -55,6 +55,8 @@ void main() {
result,
contains(
'{@Part() required String filename, @PartFile() required List<int> file}'));
expect(result, isNot(contains(' client: httpClient,\n')));
expect(result2, contains(' client: httpClient,\n'));
});
});
}

0 comments on commit 37be963

Please sign in to comment.