MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_extract_multiple_entities

Function test_extract_multiple_entities

atomic-semantic/src/parser.rs:1435–1468  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1433
1434 #[test]
1435 fn test_extract_multiple_entities() {
1436 let mut extractor = TypeScriptExtractor::new();
1437 let source = r#"
1438export interface Config {
1439 apiUrl: string;
1440}
1441
1442export const DEFAULT_CONFIG: Config = {
1443 apiUrl: 'https://api.example.com',
1444};
1445
1446export function createClient(config: Config): Client {
1447 return new Client(config);
1448}
1449
1450export class Client {
1451 constructor(private config: Config) {}
1452
1453 async request(path: string): Promise<Response> {
1454 return fetch(this.config.apiUrl + path);
1455 }
1456}
1457"#;
1458 let entities = extractor.extract(source, "test.ts");
1459
1460 // Should find: interface, const, function, class, constructor, request method
1461 assert!(entities.len() >= 5);
1462
1463 let names: Vec<&str> = entities.iter().map(|e| e.name.as_str()).collect();
1464 assert!(names.contains(&"Config"));
1465 assert!(names.contains(&"DEFAULT_CONFIG"));
1466 assert!(names.contains(&"createClient"));
1467 assert!(names.contains(&"Client"));
1468 }
1469
1470 #[test]
1471 fn test_tsx_support() {

Callers

nothing calls this directly

Calls 4

extractMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected