(expr: any, settings?: any, mode?: any, isNot?: any, expectedError?: any)
| 133 | }; |
| 134 | |
| 135 | export const expectKaTeX = (expr: any, settings?: any, mode?: any, isNot?: any, expectedError?: any) => { |
| 136 | let pass = expectedError == null; |
| 137 | let error: unknown; |
| 138 | try { |
| 139 | mode.apply(expr, settings); |
| 140 | } catch (e) { |
| 141 | error = e; |
| 142 | if (e instanceof ParseError) { |
| 143 | pass = expectedError === ParseError || (typeof expectedError === |
| 144 | "string" && e.message === `KaTeX parse error: ${expectedError}`); |
| 145 | } else if (e instanceof ConsoleWarning) { |
| 146 | pass = expectedError === ConsoleWarning; |
| 147 | } else { |
| 148 | pass = !!isNot; // always fail |
| 149 | } |
| 150 | } |
| 151 | return { |
| 152 | pass, |
| 153 | message: () => 'Expected the expression to ' + |
| 154 | printExpectedResult(mode.noun, isNot, expectedError) + |
| 155 | `:\n ${printReceived(r(expr))}\n` + |
| 156 | printActualErrorMessage(error), |
| 157 | }; |
| 158 | }; |
| 159 | |
| 160 | export const expectEquivalent = (actual: any, expected: any, settings: any, mode: any, expand: any) => { |
| 161 | const actualTree = stripPositions(mode.apply(actual, settings)); |
no test coverage detected
searching dependent graphs…