RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { orderWorkbenchTabs } from "../../../src/lib/workspace/workbenchTabs.ts";
|
||||
import { tabsToClose } from "../../../src/lib/workspace/tabActions.ts";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.svelte.ts";
|
||||
|
||||
test("mixed tabs retain their positions through title changes, closes, and new tabs", () => {
|
||||
const tabs = [
|
||||
{ id: "a", relPath: "a.md", name: "a.md", pinned: true },
|
||||
{ id: "b", relPath: "renamed.md", name: "renamed.md" },
|
||||
{ id: "plugin-a", relPath: "plugin:a", name: "New page title" },
|
||||
{ id: "plugin-b", relPath: "plugin:b", name: "Board" },
|
||||
];
|
||||
const ordered = orderWorkbenchTabs(tabs, ["plugin-a", "b", "a", "closed", "plugin-a"]);
|
||||
assert.deepEqual(ordered.map(tab => tab.id), ["plugin-a", "b", "a", "plugin-b"]);
|
||||
assert.equal(ordered[0].name, "New page title");
|
||||
assert.deepEqual(tabsToClose(ordered, "plugin:a", "after").map(tab => tab.id), ["b", "plugin-b"]);
|
||||
assert.deepEqual(tabsToClose(ordered, "renamed.md", "others").map(tab => tab.id), ["plugin-a", "plugin-b"]);
|
||||
assert.deepEqual(tabsToClose(ordered, "plugin:b", "all").map(tab => tab.id), ["plugin-a", "b", "plugin-b"]);
|
||||
});
|
||||
|
||||
test("replacing an empty or current document retains its tab position and creates a new buffer", async () => {
|
||||
const docs = new Documents({
|
||||
read: async path => path, write: async () => {}, image: async () => "",
|
||||
kind: () => "text", chrome: () => "Writing",
|
||||
}, () => {});
|
||||
docs.newTab();
|
||||
const emptyId = docs.active!.id;
|
||||
const order = ["plugin-a", emptyId, "plugin-b"];
|
||||
for (const rel_path of ["a.md", "b.md"]) {
|
||||
const previousBuffer = docs.active!.id;
|
||||
await docs.open({ rel_path, name: rel_path, kind: "file" }, "current");
|
||||
assert.notEqual(docs.active!.id, previousBuffer);
|
||||
assert.equal(docs.active!.tabId, emptyId);
|
||||
const tabs = [{ id: "plugin-a" }, { id: "plugin-b" }, { id: docs.active!.tabId! }];
|
||||
assert.deepEqual(orderWorkbenchTabs(tabs, order).map(tab => tab.id), order);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user