From 20d3ad5d50ba9afb0df99bad1f71dddc762d2032 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 15 Feb 2026 13:53:17 -0800 Subject: [PATCH] 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 --- apps/server/src/keybindings.test.ts | 16 +++++++-------- packages/contracts/src/keybindings.test.ts | 24 ++++++++++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/apps/server/src/keybindings.test.ts b/apps/server/src/keybindings.test.ts index 72c7e45d800cea594bd34a2b1c0a0a62c1be599f..db85b0a47547fd6fc17327b4d7c5eb7d4e80091d 100644 --- a/apps/server/src/keybindings.test.ts +++ b/apps/server/src/keybindings.test.ts @@ -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(); + ); }); }); diff --git a/packages/contracts/src/keybindings.test.ts b/packages/contracts/src/keybindings.test.ts index a68ffb7b14505585ce9bf6c803bdfe5d92372e5a..90dc821132a505c305c07aa0ee1a371ea817b80a 100644 --- a/packages/contracts/src/keybindings.test.ts +++ b/packages/contracts/src/keybindings.test.ts @@ -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); }); }); -- 2.54.0