test(add): cover insert_method revert/not-found paths and only_controller errors
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
1 parent
4fe5b53e7f
commit
0aee29478b
2 files changed
+39
No files matched your search
+13
@@ -304,4 +304,17 @@ export class AppModule {}
|
||||
// ...and must NOT touch the decoy array
|
||||
assert!(out.contains("controllers: [Existing] }"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_method_reverts_on_parse_break() {
|
||||
// a method body that makes the class re-parse fail must yield None (revert guard)
|
||||
let src = "export class HomeController {\n home() {}\n}\n";
|
||||
assert!(insert_method(src, "HomeController", " zen() { ]; class Evil {\n").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_method_none_when_class_absent() {
|
||||
let src = "export class HomeController {\n home() {}\n}\n";
|
||||
assert!(insert_method(src, "NotHere", " zen() {}\n").is_none());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user