cockpitTextMatches function
Implementation
bool cockpitTextMatches(
String actual,
String expected,
CockpitTextMatchMode matchMode,
) {
final normalizedActual = cockpitNormalizeText(actual);
final normalizedExpected = cockpitNormalizeText(expected);
if (normalizedActual.isEmpty || normalizedExpected.isEmpty) return false;
return switch (matchMode) {
CockpitTextMatchMode.exact => normalizedActual == normalizedExpected,
CockpitTextMatchMode.contains => normalizedActual.contains(
normalizedExpected,
),
CockpitTextMatchMode.fuzzy => cockpitFuzzyTextMatches(
normalizedActual,
normalizedExpected,
),
CockpitTextMatchMode.regex => RegExp(
expected.trim(),
).hasMatch(normalizedActual),
};
}