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

Function test_extract_class

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

Source from the content-addressed store, hash-verified

1318
1319 #[test]
1320 fn test_extract_class() {
1321 let mut extractor = TypeScriptExtractor::new();
1322 let source = r#"
1323export class UserService {
1324 private cache: Map<string, User>;
1325
1326 constructor() {
1327 this.cache = new Map();
1328 }
1329
1330 async getUser(id: string): Promise<User> {
1331 return this.cache.get(id);
1332 }
1333
1334 setUser(user: User): void {
1335 this.cache.set(user.id, user);
1336 }
1337}
1338"#;
1339 let entities = extractor.extract(source, "test.ts");
1340
1341 // Should find: class, constructor, getUser, setUser
1342 assert!(entities.len() >= 3);
1343
1344 let class_entity = entities.iter().find(|e| e.name == "UserService");
1345 assert!(class_entity.is_some());
1346 assert_eq!(class_entity.unwrap().kind, EntityKind::Class);
1347 assert!(class_entity.unwrap().exported);
1348
1349 let method_entity = entities.iter().find(|e| e.name == "getUser");
1350 assert!(method_entity.is_some());
1351 assert_eq!(method_entity.unwrap().kind, EntityKind::Method);
1352 }
1353
1354 #[test]
1355 fn test_extract_interface() {

Callers

nothing calls this directly

Calls 2

extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected