Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix GREYDirection type mismatch #231

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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