From ff3a72968ab55b5b59204bbc37c9cd76076f5420 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 15 Feb 2022 02:59:54 +0530 Subject: [PATCH] feat: add tests for actions --- src/test.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/test.rs b/src/test.rs index 077bd63..fe2b4bb 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1,4 +1,4 @@ -use crate::config::{Match, Matcher}; +use crate::config::{Act, Action, Match, Matcher}; #[test] fn regex_matcher() { @@ -8,3 +8,30 @@ fn regex_matcher() { assert!(matcher.check_match("https://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")); +}