Use Vitest assert API in keybindings tests

- Replace `expect` assertions with `assert` in server and contracts keybinding tests
- Keep existing coverage while standardizing assertion style
This commit is contained in:
Julius Marminge committed 2026-02-15 13:53:17 -08:00
1 parent 3b2f559d7e
commit 3e1bfcbbbb
2 files changed
+21 -19

No files matched your search

+8 -8
View File
@@ -1,10 +1,10 @@
import { describe, expect, it } from "vitest";
import { assert, describe, it } from "vitest";
import { compileResolvedKeybindingRule, parseKeybindingShortcut } from "./keybindings";
describe("server keybindings", () => {
it("parses shortcuts including plus key", () => {
expect(parseKeybindingShortcut("mod+j")).toEqual({
assert.deepEqual(parseKeybindingShortcut("mod+j"), {
key: "j",
metaKey: false,
ctrlKey: false,
@@ -12,7 +12,7 @@ describe("server keybindings", () => {
altKey: false,
modKey: true,
});
expect(parseKeybindingShortcut("mod++")).toEqual({
assert.deepEqual(parseKeybindingShortcut("mod++"), {
key: "+",
metaKey: false,
ctrlKey: false,
@@ -29,7 +29,7 @@ describe("server keybindings", () => {
when: "terminalOpen && !terminalFocus",
});
expect(compiled).toEqual({
assert.deepEqual(compiled, {
key: "mod+d",
command: "terminal.split",
when: "terminalOpen && !terminalFocus",
@@ -53,19 +53,19 @@ describe("server keybindings", () => {
});
it("rejects invalid rules", () => {
expect(
assert.isNull(
compileResolvedKeybindingRule({
key: "mod+shift+d+o",
command: "terminal.new",
}),
).toBeNull();
);
expect(
assert.isNull(
compileResolvedKeybindingRule({
key: "mod+d",
command: "terminal.split",
when: "terminalFocus && (",
}),
).toBeNull();
);
});
});
+13 -11
View File
@@ -1,4 +1,4 @@
import { describe, expect, it } from "vitest";
import { assert, describe, it } from "vitest";
import {
keybindingRuleSchema,
@@ -13,16 +13,18 @@ describe("keybindings contracts", () => {
key: "mod+j",
command: "terminal.toggle",
});
expect(parsed.command).toBe("terminal.toggle");
assert.strictEqual(parsed.command, "terminal.toggle");
});
it("rejects invalid command values", () => {
expect(() =>
keybindingRuleSchema.parse({
key: "mod+j",
command: "invalid.command" as unknown as "terminal.toggle",
}),
).toThrow();
assert.throws(() =>
keybindingRuleSchema.parse(
{
key: "mod+j",
command: "invalid.command" as unknown as "terminal.toggle",
},
),
);
});
it("parses keybindings array payload", () => {
@@ -30,7 +32,7 @@ describe("keybindings contracts", () => {
{ key: "mod+j", command: "terminal.toggle" },
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
]);
expect(parsed).toHaveLength(2);
assert.lengthOf(parsed, 2);
});
it("parses resolved keybinding rules", () => {
@@ -55,7 +57,7 @@ describe("keybindings contracts", () => {
},
},
});
expect(parsed.shortcut.key).toBe("d");
assert.strictEqual(parsed.shortcut.key, "d");
});
it("parses resolved keybindings arrays", () => {
@@ -73,6 +75,6 @@ describe("keybindings contracts", () => {
},
},
]);
expect(parsed).toHaveLength(1);
assert.lengthOf(parsed, 1);
});
});