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

Function test_extract_class

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

Source from the content-addressed store, hash-verified

1245
1246 #[test]
1247 fn test_extract_class() {
1248 let mut extractor = TypeScriptExtractor::new();
1249 let source = r#"
1250export class UserService {
1251 private cache: Map<string, User>;
1252
1253 constructor() {
1254 this.cache = new Map();
1255 }
1256
1257 async getUser(id: string): Promise<User> {
1258 return this.cache.get(id);
1259 }
1260
1261 setUser(user: User): void {
1262 this.cache.set(user.id, user);
1263 }
1264}
1265"#;
1266 let entities = extractor.extract(source, "test.ts");
1267
1268 // Should find: class, constructor, getUser, setUser
1269 assert!(entities.len() >= 3);
1270
1271 let class_entity = entities.iter().find(|e| e.name == "UserService");
1272 assert!(class_entity.is_some());
1273 assert_eq!(class_entity.unwrap().kind, EntityKind::Class);
1274 assert!(class_entity.unwrap().exported);
1275
1276 let method_entity = entities.iter().find(|e| e.name == "getUser");
1277 assert!(method_entity.is_some());
1278 assert_eq!(method_entity.unwrap().kind, EntityKind::Method);
1279 }
1280
1281 #[test]
1282 fn test_extract_interface() {

Callers

nothing calls this directly

Calls 2

extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected