diff --git a/detox/src/ios/earlgreyapi/GREYActions.js b/detox/src/ios/earlgreyapi/GREYActions.js index ab7bb0be32..7673e382dc 100644 --- a/detox/src/ios/earlgreyapi/GREYActions.js +++ b/detox/src/ios/earlgreyapi/GREYActions.js @@ -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) { diff --git a/detox/src/ios/earlgreyapi/GREYMatchers.js b/detox/src/ios/earlgreyapi/GREYMatchers.js index 92b328bfda..3ef6ce8cee 100644 --- a/detox/src/ios/earlgreyapi/GREYMatchers.js +++ b/detox/src/ios/earlgreyapi/GREYMatchers.js @@ -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. @@ -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 { diff --git a/generation/core/type-checks.js b/generation/core/type-checks.js index df2ab6cc1f..9deeea8704 100644 --- a/generation/core/type-checks.js +++ b/generation/core/type-checks.js @@ -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)