mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-20 21:04:45 +08:00
fix: react key warnings from duplicate message IDs + establish jest testing framework (#655)
* fix: resolve issue #588 - react key warnings from duplicate message IDs + establish jest testing framework * Update the makefile and workflow with the js test * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { describe, it } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import katex from "katex";
|
||||
|
||||
import { katexOptions } from "../src/core/markdown/katex.ts";
|
||||
import { katexOptions } from "../src/core/markdown/katex";
|
||||
|
||||
function render(expression: string) {
|
||||
return katex.renderToString(expression, {
|
||||
@@ -14,26 +11,26 @@ function render(expression: string) {
|
||||
|
||||
describe("markdown physics katex support", () => {
|
||||
it("renders vector calculus operators", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
expect(() => {
|
||||
render("\\curl{\\vect{B}} = \\mu_0 \\vect{J} + \\mu_0 \\varepsilon_0 \\pdv{\\vect{E}}{t}");
|
||||
});
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("renders quantum mechanics bra-ket notation", () => {
|
||||
const html = render("\\braket{\\psi}{\\phi}");
|
||||
assert.ok(html.includes("⟨") && html.includes("⟩"));
|
||||
expect(html.includes("⟨") && html.includes("⟩")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("renders vector magnitude formula with subscripts and square root", () => {
|
||||
const html = render("(F_1) (F_2), (F=\\sqrt{F_1^2+F_2^2})");
|
||||
assert.ok(html.includes("F"));
|
||||
assert.ok(html.includes("₁") || html.includes("sub")); // subscript check
|
||||
assert.ok(html.includes("√") || html.includes("sqrt")); // square root check
|
||||
const html = render("(F_1) (F_2), (F=\\sqrt{F_1^2+F_2^2})");
|
||||
expect(html.includes("F")).toBeTruthy();
|
||||
expect(html.includes("₁") || html.includes("sub")).toBeTruthy(); // subscript check
|
||||
expect(html.includes("√") || html.includes("sqrt")).toBeTruthy(); // square root check
|
||||
});
|
||||
|
||||
it("renders chemical equations via mhchem", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
expect(() => {
|
||||
render("\\ce{H2O ->[\\Delta] H+ + OH-}");
|
||||
});
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user