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

Function test_extract_class

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

Source from the content-addressed store, hash-verified

1290
1291 #[test]
1292 fn test_extract_class() {
1293 let mut extractor = TypeScriptExtractor::new();
1294 let source = r#"
1295export class UserService {
1296 private cache: Map<string, User>;
1297
1298 constructor() {
1299 this.cache = new Map();
1300 }
1301
1302 async getUser(id: string): Promise<User> {
1303 return this.cache.get(id);
1304 }
1305
1306 setUser(user: User): void {
1307 this.cache.set(user.id, user);
1308 }
1309}
1310"#;
1311 let entities = extractor.extract(source, "test.ts");
1312
1313 // Should find: class, constructor, getUser, setUser
1314 assert!(entities.len() >= 3);
1315
1316 let class_entity = entities.iter().find(|e| e.name == "UserService");
1317 assert!(class_entity.is_some());
1318 assert_eq!(class_entity.unwrap().kind, EntityKind::Class);
1319 assert!(class_entity.unwrap().exported);
1320
1321 let method_entity = entities.iter().find(|e| e.name == "getUser");
1322 assert!(method_entity.is_some());
1323 assert_eq!(method_entity.unwrap().kind, EntityKind::Method);
1324 }
1325
1326 #[test]
1327 fn test_extract_interface() {

Callers

nothing calls this directly

Calls 2

extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected