Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

909 B
Raw Blame
import { describe, expect, it } from "vitest";
import { EditorState } from "@codemirror/state";
import { json } from "@codemirror/lang-json";
import { ensureSyntaxTree, foldable } from "@codemirror/language";

describe("Redis JSON editor folding", () => {
  it("provides foldable ranges for JSON objects and arrays", () => {
    const state = EditorState.create({
      doc: `{
  "items": [
    1,
    2
  ]
}`,
      extensions: [json()],
    });
    ensureSyntaxTree(state, state.doc.length);

    const objectLine = state.doc.line(1);
    const arrayLine = state.doc.line(2);
    const arrayCloseLine = state.doc.line(5);

    expect(foldable(state, objectLine.from, objectLine.to)).toEqual({ from: objectLine.to, to: state.doc.line(6).from });
    expect(foldable(state, arrayLine.from, arrayLine.to)).toEqual({ from: arrayLine.to, to: arrayCloseLine.from + arrayCloseLine.text.indexOf("]") });
  });
});