From 77737dbab6a268732cc8ddcce5f4de3b67adec13 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Fri, 15 Jan 2021 19:45:17 -0500 Subject: [PATCH] Add TestCondition_evaluateWithBodyHTMLPattern --- core/condition_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/condition_test.go b/core/condition_test.go index 53275af8..3b18240b 100644 --- a/core/condition_test.go +++ b/core/condition_test.go @@ -394,6 +394,20 @@ func TestCondition_evaluateWithBodyStringPattern(t *testing.T) { } } +func TestCondition_evaluateWithBodyHTMLPattern(t *testing.T) { + var html = `
john.doe
` + condition := Condition("[BODY] == pat(*
john.doe
*)") + result := &Result{Body: []byte(html)} + condition.evaluate(result) + if !result.ConditionResults[0].Success { + t.Errorf("Condition '%s' should have been a success", condition) + } + expectedConditionDisplayed := "[BODY] == pat(*
john.doe
*)" + if result.ConditionResults[0].Condition != expectedConditionDisplayed { + t.Errorf("Condition '%s' should have resolved to '%s', got '%s'", condition, expectedConditionDisplayed, result.ConditionResults[0].Condition) + } +} + func TestCondition_evaluateWithBodyStringPatternFailure(t *testing.T) { condition := Condition("[BODY].name == pat(bob*)") result := &Result{Body: []byte("{\"name\": \"john.doe\"}")}