test
This commit is contained in:
@@ -72,3 +72,34 @@ fn encode_str(s: &str) -> String {
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_qjs_01() {
|
||||
let qjs = CommitMsgCheckQuickJs::new_from_js(r##"
|
||||
function check(a) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function hint() {
|
||||
return "hello";
|
||||
}
|
||||
"##).unwrap();
|
||||
assert_eq!(false, qjs.check("aa"));
|
||||
assert_eq!(false, qjs.check("'\""));
|
||||
assert_eq!(false, qjs.check("'\"\n\r"));
|
||||
qjs.print_hint();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_qjs_02() {
|
||||
let qjs = CommitMsgCheckQuickJs::new_from_js(r##"
|
||||
function check(msg) {
|
||||
return msg.startsWith('feat: ');
|
||||
}
|
||||
|
||||
function hint() {
|
||||
return "hello";
|
||||
}
|
||||
"##).unwrap();
|
||||
assert_eq!(true, qjs.check("feat: xxx"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user