Skip to content

Commit

Permalink
chore: adds an integration test for the recent relative path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
devmil committed Sep 27, 2023
1 parent b4c1d34 commit 20047d0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/integration_tests/cli/extract_command_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:convert';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:dart_apitool/api_tool_cli.dart';
import 'package:test/test.dart';
Expand Down Expand Up @@ -34,6 +37,44 @@ void main() {
timeout: integrationTestTimeout,
);

test(
'packages with path dependencies don\'t yield unresolvable types',
() async {
final tempDir = await Directory.systemTemp.createTemp();
final tempFilePath = path.join(tempDir.path, 'extract_paths_test.json');
final exitCode = await runner.run([
'extract',
'--input',
path.join(
'test',
'test_packages',
'path_references',
'cluster_a',
'package_a',
),
'--output',
tempFilePath,
]);
expect(exitCode, 0);

final jsonReportFile = File(tempFilePath);
expect(await jsonReportFile.exists(), isTrue);

final jsonReport = jsonDecode(await jsonReportFile.readAsString());
await tempDir.delete(recursive: true);

// check if the ClassB field in ClassA has resolved its type
final interfaceDeclarations =
jsonReport['packageApi']['interfaceDeclarations'] as List;
final classADeclaration =
interfaceDeclarations.singleWhere((id) => id['name'] == 'ClassA');
final classBField = (classADeclaration['fieldDeclarations'] as List)
.singleWhere((fd) => fd['name'] == 'classB');
expect(classBField['typeName'], 'ClassB');
},
timeout: integrationTestTimeout,
);

test(
'Can handle pub ref',
() async {
Expand Down

0 comments on commit 20047d0

Please sign in to comment.