mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 20:07:01 +05:30
feat: add tests for actions
This commit is contained in:
parent
86cb0fde40
commit
ff3a72968a
1 changed files with 28 additions and 1 deletions
29
src/test.rs
29
src/test.rs
|
@ -1,4 +1,4 @@
|
||||||
use crate::config::{Match, Matcher};
|
use crate::config::{Act, Action, Match, Matcher};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn regex_matcher() {
|
fn regex_matcher() {
|
||||||
|
@ -8,3 +8,30 @@ fn regex_matcher() {
|
||||||
assert!(matcher.check_match("https://example.com"));
|
assert!(matcher.check_match("https://example.com"));
|
||||||
assert!(!matcher.check_match("example.com"));
|
assert!(!matcher.check_match("example.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_action() {
|
||||||
|
let action = Action::Set { content: "doe" };
|
||||||
|
assert_eq!("doe", action.apply_action("john"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn replace_action() {
|
||||||
|
let action = Action::Replace {
|
||||||
|
from: "doe",
|
||||||
|
to: "bow",
|
||||||
|
};
|
||||||
|
assert_eq!("john bow", action.apply_action("john doe"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prefix_action() {
|
||||||
|
let action = Action::Prefix { prefix: "hello " };
|
||||||
|
assert_eq!("hello john", action.apply_action("john"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn suffix_action() {
|
||||||
|
let action = Action::Suffix { suffix: " doe" };
|
||||||
|
assert_eq!("john doe", action.apply_action("john"));
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue