Skip to content

Commit

Permalink
apply new prettier settings on generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed May 8, 2018
1 parent ce97aba commit 5f435e9
Show file tree
Hide file tree
Showing 11 changed files with 2,488 additions and 2,886 deletions.
275 changes: 122 additions & 153 deletions detox/src/android/espressoapi/DetoxAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,167 +5,136 @@
*/

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 + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "multiClick",
args: [
{
type: "Integer",
value: times
}
]
};
}
static multiClick(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
}
]
};
}

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 + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "tapAtLocation",
args: [
{
type: "Integer",
value: x
},
{
type: "Integer",
value: y
}
]
};
}
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 + ')'))));
return {
target: {
type: 'Class',
value: 'com.wix.detox.espresso.DetoxAction'
},
method: 'tapAtLocation',
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 + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollToEdge",
args: [
{
type: "Integer",
value: sanitize_android_edge(edge)
}
]
};
}
static scrollToEdge(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)
}
]
};
}

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 + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollInDirection",
args: [
{
type: "Integer",
value: sanitize_android_direction(direction)
},
{
type: "Double",
value: amountInDP
}
]
};
}
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 + ')'))));
return {
target: {
type: 'Class',
value: 'com.wix.detox.espresso.DetoxAction'
},
method: 'scrollInDirection',
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 + ")")))
);
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "swipeInDirection",
args: [
{
type: "Integer",
value: sanitize_android_direction(direction)
},
{
type: "boolean",
value: fast
}
]
};
}
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 + ')'))));
return {
target: {
type: 'Class',
value: 'com.wix.detox.espresso.DetoxAction'
},
method: 'swipeInDirection',
args: [
{
type: 'Integer',
value: sanitize_android_direction(direction)
},
{
type: 'boolean',
value: fast
}
]
};
}
}

module.exports = DetoxAction;
Loading

0 comments on commit 5f435e9

Please sign in to comment.