mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-11 22:53:04 +00:00
test(dart): add integration tests for await and widget-tree call patterns
This commit is contained in:
parent
ec5cc623fb
commit
8490e99732
5 changed files with 97 additions and 0 deletions
6
gitnexus/test/fixtures/lang-resolution/dart-await-calls/app.dart
vendored
Normal file
6
gitnexus/test/fixtures/lang-resolution/dart-await-calls/app.dart
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import 'service.dart';
|
||||
|
||||
Future<void> run() async {
|
||||
final user = await fetchUser();
|
||||
await processData(user);
|
||||
}
|
||||
5
gitnexus/test/fixtures/lang-resolution/dart-await-calls/service.dart
vendored
Normal file
5
gitnexus/test/fixtures/lang-resolution/dart-await-calls/service.dart
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Future<String> fetchUser() async {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
Future<void> processData(String data) async {}
|
||||
10
gitnexus/test/fixtures/lang-resolution/dart-widget-tree-calls/app.dart
vendored
Normal file
10
gitnexus/test/fixtures/lang-resolution/dart-widget-tree-calls/app.dart
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import 'builders.dart';
|
||||
|
||||
// Named argument call: child: buildHeader()
|
||||
// List literal calls: children: [buildBody(), buildFooter()]
|
||||
dynamic buildPage() {
|
||||
return Column(
|
||||
child: buildHeader(),
|
||||
children: [buildBody(), buildFooter()],
|
||||
);
|
||||
}
|
||||
3
gitnexus/test/fixtures/lang-resolution/dart-widget-tree-calls/builders.dart
vendored
Normal file
3
gitnexus/test/fixtures/lang-resolution/dart-widget-tree-calls/builders.dart
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
dynamic buildHeader() => null;
|
||||
dynamic buildBody() => null;
|
||||
dynamic buildFooter() => null;
|
||||
|
|
@ -512,3 +512,76 @@ describe.skipIf(!dartAvailable)(
|
|||
});
|
||||
},
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// await call patterns: await fetchUser(), await processData()
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe.skipIf(!dartAvailable)('Dart await call resolution', () => {
|
||||
let result: PipelineResult;
|
||||
|
||||
beforeAll(async () => {
|
||||
result = await runPipelineFromRepo(
|
||||
path.join(FIXTURES, 'dart-await-calls'),
|
||||
() => {},
|
||||
);
|
||||
}, 60000);
|
||||
|
||||
it('detects fetchUser and processData as functions', () => {
|
||||
const fns = getNodesByLabel(result, 'Function');
|
||||
expect(fns).toContain('fetchUser');
|
||||
expect(fns).toContain('processData');
|
||||
});
|
||||
|
||||
it('resolves run → fetchUser via await direct call', () => {
|
||||
const calls = getRelationships(result, 'CALLS');
|
||||
const edge = calls.find((c) => c.source === 'run' && c.target === 'fetchUser');
|
||||
expect(edge).toBeDefined();
|
||||
});
|
||||
|
||||
it('resolves run → processData via await direct call', () => {
|
||||
const calls = getRelationships(result, 'CALLS');
|
||||
const edge = calls.find((c) => c.source === 'run' && c.target === 'processData');
|
||||
expect(edge).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Widget-tree call patterns: named argument and list literal
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe.skipIf(!dartAvailable)('Dart widget-tree call resolution', () => {
|
||||
let result: PipelineResult;
|
||||
|
||||
beforeAll(async () => {
|
||||
result = await runPipelineFromRepo(
|
||||
path.join(FIXTURES, 'dart-widget-tree-calls'),
|
||||
() => {},
|
||||
);
|
||||
}, 60000);
|
||||
|
||||
it('detects buildHeader, buildBody, buildFooter as functions', () => {
|
||||
const fns = getNodesByLabel(result, 'Function');
|
||||
expect(fns).toContain('buildHeader');
|
||||
expect(fns).toContain('buildBody');
|
||||
expect(fns).toContain('buildFooter');
|
||||
});
|
||||
|
||||
it('resolves buildPage → buildHeader via named argument call', () => {
|
||||
const calls = getRelationships(result, 'CALLS');
|
||||
const edge = calls.find((c) => c.source === 'buildPage' && c.target === 'buildHeader');
|
||||
expect(edge).toBeDefined();
|
||||
});
|
||||
|
||||
it('resolves buildPage → buildBody via list literal call', () => {
|
||||
const calls = getRelationships(result, 'CALLS');
|
||||
const edge = calls.find((c) => c.source === 'buildPage' && c.target === 'buildBody');
|
||||
expect(edge).toBeDefined();
|
||||
});
|
||||
|
||||
it('resolves buildPage → buildFooter via list literal call', () => {
|
||||
const calls = getRelationships(result, 'CALLS');
|
||||
const edge = calls.find((c) => c.source === 'buildPage' && c.target === 'buildFooter');
|
||||
expect(edge).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue