Skip to content

Commit

Permalink
ensure generation delivers prettified code
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Schmidt authored and DanielMSchmidt committed Apr 25, 2018
1 parent 3227c2a commit c2e51c4
Show file tree
Hide file tree
Showing 10 changed files with 1,605 additions and 707 deletions.
181 changes: 111 additions & 70 deletions detox/src/android/espressoapi/DetoxAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,127 +4,168 @@
For more information see generation/README.md.
*/


function sanitize_android_edge(edge) {
switch (edge) {
case "left":
return 1;
case "right":
return 2;
case "top":
return 3;
case "bottom":
return 4;
default:
throw new Error(
`edge must be a 'left'/'right'/'top'/'bottom', got ${edge}`
);
}
}
switch (edge) {
case "left":
return 1;
case "right":
return 2;
case "top":
return 3;
case "bottom":
return 4;
default:
throw new Error(
`edge must be a 'left'/'right'/'top'/'bottom', got ${edge}`
);
}
}
function sanitize_android_direction(direction) {
switch (direction) {
case "left":
return 1;
case "right":
return 2;
case "up":
return 3;
case "down":
return 4;
default:
throw new Error(
`direction must be a 'left'/'right'/'up'/'down', got ${direction}`
);
}
}
switch (direction) {
case "left":
return 1;
case "right":
return 2;
case "up":
return 3;
case "down":
return 4;
default:
throw new Error(
`direction must be a 'left'/'right'/'up'/'down', got ${direction}`
);
}
}
class DetoxAction {
static multiClick(times) {
if (typeof times !== "number") throw new Error("times should be a number, but got " + (times + (" (" + (typeof times + ")"))));
if (typeof times !== "number")
throw new Error(
"times should be a number, but got " +
(times + (" (" + (typeof times + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "multiClick",
args: [{
type: "Integer",
value: times
}]
args: [
{
type: "Integer",
value: times
}
]
};
}

static tapAtLocation(x, y) {
if (typeof x !== "number") throw new Error("x should be a number, but got " + (x + (" (" + (typeof x + ")"))));
if (typeof y !== "number") throw new Error("y should be a number, but got " + (y + (" (" + (typeof y + ")"))));
if (typeof x !== "number")
throw new Error(
"x should be a number, but got " + (x + (" (" + (typeof x + ")")))
);
if (typeof y !== "number")
throw new Error(
"y should be a number, but got " + (y + (" (" + (typeof y + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "tapAtLocation",
args: [{
type: "Integer",
value: x
}, {
type: "Integer",
value: y
}]
args: [
{
type: "Integer",
value: x
},
{
type: "Integer",
value: y
}
]
};
}

static scrollToEdge(edge) {
if (typeof edge !== "string") throw new Error("edge should be a string, but got " + (edge + (" (" + (typeof edge + ")"))));
if (typeof edge !== "string")
throw new Error(
"edge should be a string, but got " +
(edge + (" (" + (typeof edge + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollToEdge",
args: [{
type: "Integer",
value: sanitize_android_edge(edge)
}]
args: [
{
type: "Integer",
value: sanitize_android_edge(edge)
}
]
};
}

static scrollInDirection(direction, amountInDP) {
if (typeof direction !== "string") throw new Error("direction should be a string, but got " + (direction + (" (" + (typeof direction + ")"))));
if (typeof amountInDP !== "number") throw new Error("amountInDP should be a number, but got " + (amountInDP + (" (" + (typeof amountInDP + ")"))));
if (typeof direction !== "string")
throw new Error(
"direction should be a string, but got " +
(direction + (" (" + (typeof direction + ")")))
);
if (typeof amountInDP !== "number")
throw new Error(
"amountInDP should be a number, but got " +
(amountInDP + (" (" + (typeof amountInDP + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollInDirection",
args: [{
type: "Integer",
value: sanitize_android_direction(direction)
}, {
type: "Double",
value: amountInDP
}]
args: [
{
type: "Integer",
value: sanitize_android_direction(direction)
},
{
type: "Double",
value: amountInDP
}
]
};
}

static swipeInDirection(direction, fast) {
if (typeof direction !== "string") throw new Error("direction should be a string, but got " + (direction + (" (" + (typeof direction + ")"))));
if (typeof fast !== "boolean") throw new Error("fast should be a boolean, but got " + (fast + (" (" + (typeof fast + ")"))));
if (typeof direction !== "string")
throw new Error(
"direction should be a string, but got " +
(direction + (" (" + (typeof direction + ")")))
);
if (typeof fast !== "boolean")
throw new Error(
"fast should be a boolean, but got " +
(fast + (" (" + (typeof fast + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "swipeInDirection",
args: [{
type: "Integer",
value: sanitize_android_direction(direction)
}, {
type: "boolean",
value: fast
}]
args: [
{
type: "Integer",
value: sanitize_android_direction(direction)
},
{
type: "boolean",
value: fast
}
]
};
}

}

module.exports = DetoxAction;
module.exports = DetoxAction;
Loading

0 comments on commit c2e51c4

Please sign in to comment.