-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move DetoxAssertion to generated code
Closes #726
- Loading branch information
Daniel Schmidt
committed
Aug 8, 2018
1 parent
c81147c
commit bd95938
Showing
6 changed files
with
266 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/** | ||
This code is generated. | ||
For more information see generation/README.md. | ||
*/ | ||
|
||
|
||
function sanitize_matcher(matcher) { | ||
const originalMatcher = typeof matcher._call === 'function' ? matcher._call() : matcher._call; | ||
return originalMatcher.type ? originalMatcher.value : originalMatcher; | ||
} | ||
class DetoxAssertion { | ||
static assertMatcher(i, m) { | ||
if (typeof m !== 'object' || typeof m.constructor !== 'function' || m.constructor.name.indexOf('Matcher') === -1) { | ||
const isObject = typeof m === 'object'; | ||
const additionalErrorInfo = isObject ? typeof m.constructor === 'object' ? 'the constructor is no object' : 'it has a wrong class name: "' + m.constructor.name + '"' : 'it is no object'; | ||
throw new Error('m should be an instance of Matcher, got "' + m + '", it appears that ' + additionalErrorInfo); | ||
} | ||
|
||
return { | ||
target: { | ||
type: "Class", | ||
value: "com.wix.detox.espresso.DetoxAssertion" | ||
}, | ||
method: "assertMatcher", | ||
args: [{ | ||
type: "ViewInteraction", | ||
value: i | ||
}, { | ||
type: "Invocation", | ||
value: sanitize_matcher(m) | ||
}] | ||
}; | ||
} | ||
|
||
static assertNotVisible(i) { | ||
return { | ||
target: { | ||
type: "Class", | ||
value: "com.wix.detox.espresso.DetoxAssertion" | ||
}, | ||
method: "assertNotVisible", | ||
args: [{ | ||
type: "ViewInteraction", | ||
value: i | ||
}] | ||
}; | ||
} | ||
|
||
static assertNotExists(i) { | ||
return { | ||
target: { | ||
type: "Class", | ||
value: "com.wix.detox.espresso.DetoxAssertion" | ||
}, | ||
method: "assertNotExists", | ||
args: [{ | ||
type: "ViewInteraction", | ||
value: i | ||
}] | ||
}; | ||
} | ||
|
||
static waitForAssertMatcher(i, m, timeoutSeconds) { | ||
if (typeof m !== 'object' || typeof m.constructor !== 'function' || m.constructor.name.indexOf('Matcher') === -1) { | ||
const isObject = typeof m === 'object'; | ||
const additionalErrorInfo = isObject ? typeof m.constructor === 'object' ? 'the constructor is no object' : 'it has a wrong class name: "' + m.constructor.name + '"' : 'it is no object'; | ||
throw new Error('m should be an instance of Matcher, got "' + m + '", it appears that ' + additionalErrorInfo); | ||
} | ||
|
||
if (typeof timeoutSeconds !== "number") throw new Error("timeoutSeconds should be a number, but got " + (timeoutSeconds + (" (" + (typeof timeoutSeconds + ")")))); | ||
return { | ||
target: { | ||
type: "Class", | ||
value: "com.wix.detox.espresso.DetoxAssertion" | ||
}, | ||
method: "waitForAssertMatcher", | ||
args: [{ | ||
type: "ViewInteraction", | ||
value: i | ||
}, { | ||
type: "Invocation", | ||
value: sanitize_matcher(m) | ||
}, { | ||
type: "Double", | ||
value: timeoutSeconds | ||
}] | ||
}; | ||
} | ||
|
||
static waitForAssertMatcherWithSearchAction(i, m, searchAction, searchMatcher) { | ||
if (typeof m !== 'object' || typeof m.constructor !== 'function' || m.constructor.name.indexOf('Matcher') === -1) { | ||
const isObject = typeof m === 'object'; | ||
const additionalErrorInfo = isObject ? typeof m.constructor === 'object' ? 'the constructor is no object' : 'it has a wrong class name: "' + m.constructor.name + '"' : 'it is no object'; | ||
throw new Error('m should be an instance of Matcher, got "' + m + '", it appears that ' + additionalErrorInfo); | ||
} | ||
|
||
if (typeof searchMatcher !== 'object' || typeof searchMatcher.constructor !== 'function' || searchMatcher.constructor.name.indexOf('Matcher') === -1) { | ||
const isObject = typeof searchMatcher === 'object'; | ||
const additionalErrorInfo = isObject ? typeof searchMatcher.constructor === 'object' ? 'the constructor is no object' : 'it has a wrong class name: "' + searchMatcher.constructor.name + '"' : 'it is no object'; | ||
throw new Error('searchMatcher should be an instance of Matcher, got "' + searchMatcher + '", it appears that ' + additionalErrorInfo); | ||
} | ||
|
||
return { | ||
target: { | ||
type: "Class", | ||
value: "com.wix.detox.espresso.DetoxAssertion" | ||
}, | ||
method: "waitForAssertMatcherWithSearchAction", | ||
args: [{ | ||
type: "ViewInteraction", | ||
value: i | ||
}, { | ||
type: "Invocation", | ||
value: sanitize_matcher(m) | ||
}, { | ||
type: "ViewAction", | ||
value: searchAction | ||
}, { | ||
type: "Invocation", | ||
value: sanitize_matcher(searchMatcher) | ||
}] | ||
}; | ||
} | ||
|
||
} | ||
|
||
module.exports = DetoxAssertion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.