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 error message to not state false information #495

Merged
merged 1 commit into from
Jan 8, 2018
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
60 changes: 32 additions & 28 deletions detox/src/ios/earlgreyapi/GREYActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,39 @@


function sanitize_greyDirection(action) {
switch (action) {
case "left":
return 1;
case "right":
return 2;
case "up":
return 3;
case "down":
return 4;

default:
throw new Error(`GREYAction.GREYDirection must be a 'left'/'right'/'up'/'down', got ${action}`);
}
}
switch (action) {
case "left":
return 1;
case "right":
return 2;
case "up":
return 3;
case "down":
return 4;

default:
throw new Error(
`GREYAction.GREYDirection must be a 'left'/'right'/'up'/'down', got ${action}`
);
}
}
function sanitize_greyContentEdge(action) {
switch (action) {
case "left":
return 0;
case "right":
return 1;
case "top":
return 2;
case "bottom":
return 3;

default:
throw new Error(`GREYAction.GREYContentEdge must be a 'left'/'right'/'top'/'bottom', got ${action}`);
}
}
switch (action) {
case "left":
return 0;
case "right":
return 1;
case "top":
return 2;
case "bottom":
return 3;

default:
throw new Error(
`GREYAction.GREYContentEdge must be a 'left'/'right'/'top'/'bottom', got ${action}`
);
}
}
class GREYActions {
/*@return A GREYAction that performs multiple taps of a specified @c count.
*/static actionForMultipleTapsWithCount(count) {
Expand Down
119 changes: 79 additions & 40 deletions detox/src/ios/earlgreyapi/GREYMatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,85 @@


function sanitize_uiAccessibilityTraits(value) {
let traits = 0;
for (let i = 0; i < value.length; i++) {
switch (value[i]) {
case 'button': traits |= 1; break;
case 'link': traits |= 2; break;
case 'header': traits |= 4; break;
case 'search': traits |= 8; break;
case 'image': traits |= 16; break;
case 'selected': traits |= 32; break;
case 'plays': traits |= 64; break;
case 'key': traits |= 128; break;
case 'text': traits |= 256; break;
case 'summary': traits |= 512; break;
case 'disabled': traits |= 1024; break;
case 'frequentUpdates': traits |= 2048; break;
case 'startsMedia': traits |= 4096; break;
case 'adjustable': traits |= 8192; break;
case 'allowsDirectInteraction': traits |= 16384; break;
case 'pageTurn': traits |= 32768; break;
default: throw new Error(`Unknown trait '${value[i]}', see list in https://facebook.github.io/react-native/docs/accessibility.html#accessibilitytraits-ios`);
}
}

return traits;
}
let traits = 0;
for (let i = 0; i < value.length; i++) {
switch (value[i]) {
case "button":
traits |= 1;
break;
case "link":
traits |= 2;
break;
case "header":
traits |= 4;
break;
case "search":
traits |= 8;
break;
case "image":
traits |= 16;
break;
case "selected":
traits |= 32;
break;
case "plays":
traits |= 64;
break;
case "key":
traits |= 128;
break;
case "text":
traits |= 256;
break;
case "summary":
traits |= 512;
break;
case "disabled":
traits |= 1024;
break;
case "frequentUpdates":
traits |= 2048;
break;
case "startsMedia":
traits |= 4096;
break;
case "adjustable":
traits |= 8192;
break;
case "allowsDirectInteraction":
traits |= 16384;
break;
case "pageTurn":
traits |= 32768;
break;
default:
throw new Error(
`Unknown trait '${
value[i]
}', see list in https://facebook.github.io/react-native/docs/accessibility.html#accessibilitytraits-ios`
);
}
}

return traits;
}
function sanitize_greyContentEdge(action) {
switch (action) {
case "left":
return 0;
case "right":
return 1;
case "top":
return 2;
case "bottom":
return 3;

default:
throw new Error(`GREYAction.GREYContentEdge must be a 'left'/'right'/'top'/'bottom', got ${action}`);
}
}
switch (action) {
case "left":
return 0;
case "right":
return 1;
case "top":
return 2;
case "bottom":
return 3;

default:
throw new Error(
`GREYAction.GREYContentEdge must be a 'left'/'right'/'top'/'bottom', got ${action}`
);
}
}
class GREYMatchers {
/*Matcher for application's key window.

Expand Down Expand Up @@ -129,7 +168,7 @@ class GREYMatchers {

*/static matcherForAccessibilityTraits(traits) {
if (typeof traits !== 'object' || !traits instanceof Array) {
throw new Error('TraitsMatcher ctor argument must be an array, got ' + typeof traits);
throw new Error('traits must be an array, got ' + typeof traits);
}

return {
Expand Down
2 changes: 1 addition & 1 deletion generation/core/type-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (
(typeof ARG !== 'object') ||
(!ARG instanceof Array)
) {
throw new Error('TraitsMatcher ctor argument must be an array, got ' + typeof ARG);
throw new Error('${name} must be an array, got ' + typeof ARG);
}
`)({
ARG: t.identifier(name)
Expand Down