/
githubmirror
/
ChatGPT-Next-Web
Обзор
Документация
Войти
/
githubmirror
/
ChatGPT-Next-Web
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/format.test.ts
20 строк
650 B
TIANQIAN1238
test: add unit tests for prettyObject
06 июл 2026, 07:23
06 июл 2026, 07:23
5fc7460
Код
Авторство
О чём код?
import { prettyObject } from "../app/utils/format"; describe("prettyObject", () => { test("wraps a plain string in a json code fence", () => { expect(prettyObject("hello")).toBe("```json\nhello\n```"); }); test("stringifies and wraps a non-empty object", () => { expect(prettyObject({ a: 1 })).toBe('```json\n{\n "a": 1\n}\n```'); }); test("returns the original toString() for an empty object", () => { expect(prettyObject({})).toBe("[object Object]"); }); test("leaves an already fenced json string untouched", () => { const already = "```json\n{}\n```"; expect(prettyObject(already)).toBe(already); }); });