Absorb the local workspace drift for connection session handling, database switching, inspector readability helpers, and the bounded add-key preview flow. Co-Authored-By: Paperclip <noreply@paperclip.ing>
75 lines
1.3 KiB
TypeScript
75 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildDatabaseSwitcherLabels } from "./database-switcher";
|
|
|
|
describe("database switcher helper", () => {
|
|
it("returns the default operator range from db0 through db15", () => {
|
|
expect(buildDatabaseSwitcherLabels(0)).toEqual([
|
|
"db0",
|
|
"db1",
|
|
"db2",
|
|
"db3",
|
|
"db4",
|
|
"db5",
|
|
"db6",
|
|
"db7",
|
|
"db8",
|
|
"db9",
|
|
"db10",
|
|
"db11",
|
|
"db12",
|
|
"db13",
|
|
"db14",
|
|
"db15",
|
|
]);
|
|
});
|
|
|
|
it("keeps an active out-of-range database visible and numerically ordered", () => {
|
|
expect(buildDatabaseSwitcherLabels(23)).toEqual([
|
|
"db0",
|
|
"db1",
|
|
"db2",
|
|
"db3",
|
|
"db4",
|
|
"db5",
|
|
"db6",
|
|
"db7",
|
|
"db8",
|
|
"db9",
|
|
"db10",
|
|
"db11",
|
|
"db12",
|
|
"db13",
|
|
"db14",
|
|
"db15",
|
|
"db23",
|
|
]);
|
|
});
|
|
|
|
it("normalizes negative or fractional inputs back to safe labels", () => {
|
|
expect(buildDatabaseSwitcherLabels(-3)).toEqual([
|
|
"db0",
|
|
"db1",
|
|
"db2",
|
|
"db3",
|
|
"db4",
|
|
"db5",
|
|
"db6",
|
|
"db7",
|
|
"db8",
|
|
"db9",
|
|
"db10",
|
|
"db11",
|
|
"db12",
|
|
"db13",
|
|
"db14",
|
|
"db15",
|
|
]);
|
|
expect(buildDatabaseSwitcherLabels(4.8, 2)).toEqual([
|
|
"db0",
|
|
"db1",
|
|
"db2",
|
|
"db4",
|
|
]);
|
|
});
|
|
});
|