Skip to content

Commit e6eda81

Browse files
committed
automatically replace undefines in input
1 parent 972b397 commit e6eda81

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/selenium-ide/src/neo/__test__/models/Command.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ describe("Command", () => {
4141
command.setCommand("test invalid");
4242
expect(command.isValid).toBeFalsy();
4343
});
44+
it("should replace undefined input with empty strings", () => {
45+
const command = new Command();
46+
command.setCommand();
47+
command.setTarget();
48+
command.setValue();
49+
command.setComment();
50+
expect(command.command).toEqual("");
51+
expect(command.target).toEqual("");
52+
expect(command.value).toEqual("");
53+
expect(command.comment).toEqual("");
54+
});
4455
it("should set the target", () => {
4556
const command = new Command();
4657
command.setTarget("a");

packages/selenium-ide/src/neo/models/Command.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ export default class Command {
4545
}
4646

4747
@action.bound setComment(comment) {
48-
this.comment = comment;
48+
this.comment = comment || "";
4949
}
5050

5151
@action.bound setCommand(command) {
5252
if (CommandsValues[command]) {
5353
this.command = CommandsValues[command];
5454
} else {
55-
this.command = command;
55+
this.command = command || "";
5656
}
5757
}
5858

5959
@action.bound setTarget(target) {
60-
this.target = target;
60+
this.target = target || "";
6161
}
6262

6363
@action.bound setValue(value) {
64-
this.value = value.replace(/\n/g, "\\n");
64+
this.value = value ? value.replace(/\n/g, "\\n") : "";
6565
}
6666

6767
@action.bound toggleBreakpoint() {

0 commit comments

Comments
 (0)