mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 09:11:22 +00:00
test: dedupe and optimize test suites
This commit is contained in:
@@ -68,33 +68,28 @@ describe("resolveGatewayConnection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("uses explicit token when url override is set", () => {
|
||||
it.each([
|
||||
{
|
||||
label: "token",
|
||||
auth: { token: "explicit-token" },
|
||||
expected: { token: "explicit-token", password: undefined },
|
||||
},
|
||||
{
|
||||
label: "password",
|
||||
auth: { password: "explicit-password" },
|
||||
expected: { token: undefined, password: "explicit-password" },
|
||||
},
|
||||
])("uses explicit $label when url override is set", ({ auth, expected }) => {
|
||||
loadConfig.mockReturnValue({ gateway: { mode: "local" } });
|
||||
|
||||
const result = resolveGatewayConnection({
|
||||
url: "wss://override.example/ws",
|
||||
token: "explicit-token",
|
||||
...auth,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
url: "wss://override.example/ws",
|
||||
token: "explicit-token",
|
||||
password: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses explicit password when url override is set", () => {
|
||||
loadConfig.mockReturnValue({ gateway: { mode: "local" } });
|
||||
|
||||
const result = resolveGatewayConnection({
|
||||
url: "wss://override.example/ws",
|
||||
password: "explicit-password",
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
url: "wss://override.example/ws",
|
||||
token: undefined,
|
||||
password: "explicit-password",
|
||||
...expected,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -36,18 +36,10 @@ describe("createEditorSubmitHandler", () => {
|
||||
expect(editor.addToHistory).toHaveBeenCalledWith("hi");
|
||||
});
|
||||
|
||||
it("does not add empty-string submissions to history", () => {
|
||||
it.each(["", " "])("does not add blank submissions to history", (text) => {
|
||||
const { editor, handler } = createSubmitHarness();
|
||||
|
||||
handler("");
|
||||
|
||||
expect(editor.addToHistory).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not add whitespace-only submissions to history", () => {
|
||||
const { editor, handler } = createSubmitHarness();
|
||||
|
||||
handler(" ");
|
||||
handler(text);
|
||||
|
||||
expect(editor.addToHistory).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -79,12 +71,4 @@ describe("createEditorSubmitHandler", () => {
|
||||
|
||||
expect(handleBangLine).toHaveBeenCalledWith("!ls");
|
||||
});
|
||||
|
||||
it("treats a lone ! as a normal message", () => {
|
||||
const { sendMessage, handler } = createSubmitHarness();
|
||||
|
||||
handler("!");
|
||||
|
||||
expect(sendMessage).toHaveBeenCalledWith("!");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user