Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Use Vitest assert API in keybindings tests

Julius Marminge20d3ad5d50ba
diff --git a/apps/server/src/keybindings.test.ts b/apps/server/src/keybindings.test.ts
index 72c7e45d8..db85b0a47 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 a68ffb7b1..90dc82113 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);
});
});