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

Function test_extract_multiple_entities

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

Source from the content-addressed store, hash-verified

1360
1361 #[test]
1362 fn test_extract_multiple_entities() {
1363 let mut extractor = TypeScriptExtractor::new();
1364 let source = r#"
1365export interface Config {
1366 apiUrl: string;
1367}
1368
1369export const DEFAULT_CONFIG: Config = {
1370 apiUrl: 'https://api.example.com',
1371};
1372
1373export function createClient(config: Config): Client {
1374 return new Client(config);
1375}
1376
1377export class Client {
1378 constructor(private config: Config) {}
1379
1380 async request(path: string): Promise<Response> {
1381 return fetch(this.config.apiUrl + path);
1382 }
1383}
1384"#;
1385 let entities = extractor.extract(source, "test.ts");
1386
1387 // Should find: interface, const, function, class, constructor, request method
1388 assert!(entities.len() >= 5);
1389
1390 let names: Vec<&str> = entities.iter().map(|e| e.name.as_str()).collect();
1391 assert!(names.contains(&"Config"));
1392 assert!(names.contains(&"DEFAULT_CONFIG"));
1393 assert!(names.contains(&"createClient"));
1394 assert!(names.contains(&"Client"));
1395 }
1396
1397 #[test]
1398 fn test_tsx_support() {

Callers

nothing calls this directly

Calls 3

extractMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected