Skip to content

Commit

Permalink
fix error message to not state false information (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt authored and rotemmiz committed Jan 8, 2018
1 parent 2804ed3 commit 831e611
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 69 deletions.
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

0 comments on commit 831e611

Please sign in to comment.