Trim whitespace from command on blur
This commit is contained in:
parent
24ef31905e
commit
8d8af870ba
2 changed files with 33 additions and 0 deletions
|
|
@ -268,6 +268,7 @@ const Sidebar = ({
|
||||||
placeholder="Command"
|
placeholder="Command"
|
||||||
value={command}
|
value={command}
|
||||||
onChange={(e) => setCommand(e.target.value)}
|
onChange={(e) => setCommand(e.target.value)}
|
||||||
|
onBlur={(e) => setCommand(e.target.value.trim())}
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -878,4 +878,36 @@ describe("Sidebar Environment Variables", () => {
|
||||||
expect(mockClipboardWrite).toHaveBeenCalledWith(expectedConfig);
|
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