MCPcopy Create free account
hub / github.com/CopilotKit/OpenTag / runExpectations

Function runExpectations

e2e/telegram-run.ts:88–117  ·  view source on GitHub ↗
(
  exp: NonNullable<E2ECase["expectations"]>,
  finalText: string | undefined,
  errors: string[],
  prefix = "",
)

Source from the content-addressed store, hash-verified

86// ── Expectations runner ───────────────────────────────────────────────────────
87
88function runExpectations(
89 exp: NonNullable<E2ECase["expectations"]>,
90 finalText: string | undefined,
91 errors: string[],
92 prefix = "",
93): void {
94 const tag = prefix ? `${prefix}: ` : "";
95 if (exp.finalContains) {
96 for (const needle of exp.finalContains) {
97 if (!(finalText ?? "").toLowerCase().includes(needle.toLowerCase())) {
98 errors.push(`${tag}missing: ${JSON.stringify(needle)}`);
99 }
100 }
101 }
102 if (exp.finalNotContains) {
103 for (const needle of exp.finalNotContains) {
104 if ((finalText ?? "").toLowerCase().includes(needle.toLowerCase())) {
105 errors.push(`${tag}contained forbidden: ${JSON.stringify(needle)}`);
106 }
107 }
108 }
109 if (exp.balancedBrackets && finalText && !isBalanced(finalText)) {
110 errors.push(`${tag}text has unbalanced brackets`);
111 }
112 if (exp.minLength && (finalText?.length ?? 0) < exp.minLength) {
113 errors.push(
114 `${tag}too short (${finalText?.length ?? 0} < ${exp.minLength})`,
115 );
116 }
117}
118
119// ── Case runner ───────────────────────────────────────────────────────────────
120

Callers 1

runCaseFunction · 0.70

Calls 1

isBalancedFunction · 0.70

Tested by

no test coverage detected