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

Function test_extract_multiple_entities

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

Source from the content-addressed store, hash-verified

1405
1406 #[test]
1407 fn test_extract_multiple_entities() {
1408 let mut extractor = TypeScriptExtractor::new();
1409 let source = r#"
1410export interface Config {
1411 apiUrl: string;
1412}
1413
1414export const DEFAULT_CONFIG: Config = {
1415 apiUrl: 'https://api.example.com',
1416};
1417
1418export function createClient(config: Config): Client {
1419 return new Client(config);
1420}
1421
1422export class Client {
1423 constructor(private config: Config) {}
1424
1425 async request(path: string): Promise<Response> {
1426 return fetch(this.config.apiUrl + path);
1427 }
1428}
1429"#;
1430 let entities = extractor.extract(source, "test.ts");
1431
1432 // Should find: interface, const, function, class, constructor, request method
1433 assert!(entities.len() >= 5);
1434
1435 let names: Vec<&str> = entities.iter().map(|e| e.name.as_str()).collect();
1436 assert!(names.contains(&"Config"));
1437 assert!(names.contains(&"DEFAULT_CONFIG"));
1438 assert!(names.contains(&"createClient"));
1439 assert!(names.contains(&"Client"));
1440 }
1441
1442 #[test]
1443 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