Skip to content

Commit

Permalink
fix GREYDirection type mismatch
Browse files Browse the repository at this point in the history
This closes #228
  • Loading branch information
DanielMSchmidt committed Aug 14, 2017
1 parent 6553486 commit 9fe9d2e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
20 changes: 10 additions & 10 deletions detox/src/ios/earlgreyapi/GREYActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ simulate a long press.
},
method: "actionForScrollInDirection:amount:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "CGFloat",
Expand Down Expand Up @@ -181,7 +181,7 @@ starting from the given start points.
},
method: "actionForScrollInDirection:amount:xOriginStartPercentage:yOriginStartPercentage:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "CGFloat",
Expand Down Expand Up @@ -265,7 +265,7 @@ achieve the maximum the swipe possible to the other edge.
},
method: "actionForSwipeFastInDirection:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}]
};
Expand All @@ -286,7 +286,7 @@ achieve maximum the swipe possible to the other edge.
},
method: "actionForSwipeSlowInDirection:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}]
};
Expand Down Expand Up @@ -314,7 +314,7 @@ the specified point.
},
method: "actionForSwipeFastInDirection:xOriginStartPercentage:yOriginStartPercentage:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "CGFloat",
Expand Down Expand Up @@ -348,7 +348,7 @@ the specified point.
},
method: "actionForSwipeSlowInDirection:xOriginStartPercentage:yOriginStartPercentage:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "CGFloat",
Expand Down Expand Up @@ -378,7 +378,7 @@ direction from the specified point.
},
method: "actionForMultiFingerSwipeSlowInDirection:numberOfFingers:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "NSInteger",
Expand All @@ -405,7 +405,7 @@ direction from the specified point.
},
method: "actionForMultiFingerSwipeFastInDirection:numberOfFingers:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "NSInteger",
Expand Down Expand Up @@ -434,7 +434,7 @@ direction from the specified point.
},
method: "actionForMultiFingerSwipeSlowInDirection:numberOfFingers:xOriginStartPercentage:yOriginStartPercentage:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "NSInteger",
Expand Down Expand Up @@ -469,7 +469,7 @@ direction from the specified point.
},
method: "actionForMultiFingerSwipeFastInDirection:numberOfFingers:xOriginStartPercentage:yOriginStartPercentage:",
args: [{
type: "GREYDirection",
type: "NSInteger",
value: sanitize_greyDirection(direction)
}, {
type: "NSInteger",
Expand Down
2 changes: 1 addition & 1 deletion generation/__tests__/__snapshots__/earl-grey.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports[`earl-grey generation Invocations should sanitize the directions 1`] = `
Object {
"args": Array [
Object {
"type": "GREYDirection",
"type": "NSInteger",
"value": 4,
},
Object {
Expand Down
2 changes: 1 addition & 1 deletion generation/__tests__/earl-grey.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe("earl-grey generation", () => {
5
);

expect(result.args[0].type).toBe("GREYDirection");
expect(result.args[0].type).toBe("NSInteger");
expect(result.args[0].value).toBe(4);
expect(result).toMatchSnapshot();
});
Expand Down
19 changes: 16 additions & 3 deletions generation/earl-grey/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,33 @@ function createTypeChecks(json) {
const callGlobal = sanitizerName => argIdentifier =>
t.callExpression(t.identifier(sanitizerName), [t.identifier(argIdentifier)]);
const supportedContentSanitizersMap = {
GREYDirection: callGlobal("sanitize_greyDirection")
GREYDirection: {
type: 'NSInteger',
value: callGlobal("sanitize_greyDirection"),
},
};
function addArgumentContentSanitizerCall(json) {
if (supportedContentSanitizersMap[json.type]) {
return supportedContentSanitizersMap[json.type](json.name);
return supportedContentSanitizersMap[json.type].value(json.name);
}

return t.identifier(json.name);
}
function addArgumentTypeSanitizer(json) {
if (supportedContentSanitizersMap[json.type]) {
return supportedContentSanitizersMap[json.type].type;
}

return json.type;
}

function createReturnStatement(className, json) {
const args = json.args.map(arg =>
t.objectExpression([
t.objectProperty(t.identifier("type"), t.stringLiteral(arg.type)),
t.objectProperty(
t.identifier("type"),
t.stringLiteral(addArgumentTypeSanitizer(arg))
),
t.objectProperty(
t.identifier("value"),
addArgumentContentSanitizerCall(arg)
Expand Down

0 comments on commit 9fe9d2e

Please sign in to comment.