providerModelMapDisplay.test.ts 1.0 KB

12345678910111213141516171819202122232425
  1. import { createElement } from "react";
  2. import { renderToStaticMarkup } from "react-dom/server";
  3. import { describe, expect, it, vi } from "vitest";
  4. import { JsonSlotEditor } from "@/settings/model-provider-section/ProviderModelMetadataFields.js";
  5. describe("F98-03 Map 展示不重排源字符串", () => {
  6. it("继承 placeholder 保留换行;Personal value 保留用户空白,查看不触发 onChange", () => {
  7. const inherited = '{\n "thinking": {\n "type": "disabled"\n }\n}';
  8. const personal = '{ "thinking" : {"type":"disabled"} }';
  9. const onChange = vi.fn();
  10. for (const value of ["", personal]) {
  11. const html = renderToStaticMarkup(
  12. createElement(JsonSlotEditor, {
  13. label: "推理参数映射",
  14. value,
  15. effectiveValue: inherited,
  16. onChange,
  17. }),
  18. );
  19. expect(html).toContain(inherited.replaceAll('"', """));
  20. if (value) expect(html).toContain(personal.replaceAll('"', """));
  21. expect(onChange).not.toHaveBeenCalled();
  22. }
  23. });
  24. });