mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 16:24:33 +00:00
fix: refresh sidebar after SQL file import
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { findDatabaseTreeNode } from "../src/lib/treeRefreshTarget.ts";
|
||||
import type { TreeNode } from "../src/types/database.ts";
|
||||
|
||||
test("finds database refresh targets inside grouped sidebar trees", () => {
|
||||
const target: TreeNode = {
|
||||
id: "conn-1:app",
|
||||
label: "app",
|
||||
type: "database",
|
||||
connectionId: "conn-1",
|
||||
database: "app",
|
||||
};
|
||||
const nodes: TreeNode[] = [
|
||||
{
|
||||
id: "group-1",
|
||||
label: "Production",
|
||||
type: "connection-group",
|
||||
children: [
|
||||
{
|
||||
id: "conn-1",
|
||||
label: "mysql",
|
||||
type: "connection",
|
||||
connectionId: "conn-1",
|
||||
children: [target],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
assert.equal(findDatabaseTreeNode(nodes, "conn-1", "app"), target);
|
||||
});
|
||||
|
||||
test("returns null when the target database node is not loaded", () => {
|
||||
assert.equal(findDatabaseTreeNode([], "conn-1", "app"), null);
|
||||
});
|
||||
Reference in New Issue
Block a user