Trim whitespace from command on blur
This commit is contained in:
parent
24ef31905e
commit
8d8af870ba
1 changed files with 33 additions and 0 deletions
|
|
@ -878,4 +878,36 @@ describe("Sidebar Environment Variables", () => {
|
|||
expect(mockClipboardWrite).toHaveBeenCalledWith(expectedConfig);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Command and arguments", () => {
|
||||
it("should trim whitespace from command input on blur", () => {
|
||||
const setCommand = jest.fn();
|
||||
renderSidebar({ command: " node server.js ", setCommand });
|
||||
|
||||
const commandInput = screen.getByLabelText("Command");
|
||||
|
||||
fireEvent.blur(commandInput);
|
||||
expect(setCommand).toHaveBeenLastCalledWith("node server.js");
|
||||
});
|
||||
|
||||
it("should handle whitespace-only command input on blur", () => {
|
||||
const setCommand = jest.fn();
|
||||
renderSidebar({ command: " ", setCommand });
|
||||
|
||||
const commandInput = screen.getByLabelText("Command");
|
||||
|
||||
fireEvent.blur(commandInput);
|
||||
expect(setCommand).toHaveBeenLastCalledWith("");
|
||||
});
|
||||
|
||||
it("should not affect command without surrounding whitespace", () => {
|
||||
const setCommand = jest.fn();
|
||||
renderSidebar({ command: "node", setCommand });
|
||||
|
||||
const commandInput = screen.getByLabelText("Command");
|
||||
|
||||
fireEvent.blur(commandInput);
|
||||
expect(setCommand).toHaveBeenLastCalledWith("node");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue