detox-allure2-adapter
Version:
Detox adapter for jest-allure2-reporter
221 lines • 7.11 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RepeatedlyUntilResult = exports.OpenLinkResult = exports.TypeTextResult = exports.ScrollToResult = exports.LongClickResult = exports.DoubleClickResult = exports.KeyboardActionResult = exports.SwipeResult = exports.ClickResult = exports.ActionWithAssertionsResult = exports.ClearGlobalAssertionsResult = exports.ReplaceTextResult = exports.PressKeyResult = exports.ClearTextResult = exports.ViewActions = void 0;
const utils_1 = require("../../utils");
class ViewActions {
static clearText() {
return new ClearTextResult();
}
static pressKey(keyCode) {
return new PressKeyResult(keyCode);
}
static replaceText(stringToBeSet) {
return new ReplaceTextResult(stringToBeSet);
}
static clearGlobalAssertions() {
return new ClearGlobalAssertionsResult();
}
static actionWithAssertions(viewAction) {
return new ActionWithAssertionsResult(viewAction);
}
static click(inputDevice, buttonState) {
return new ClickResult(inputDevice, buttonState);
}
static swipeLeft() {
return new SwipeResult('left');
}
static swipeRight() {
return new SwipeResult('right');
}
static swipeDown() {
return new SwipeResult('down');
}
static swipeUp() {
return new SwipeResult('up');
}
static closeSoftKeyboard() {
return new KeyboardActionResult('Close soft keyboard');
}
static pressImeActionButton() {
return new KeyboardActionResult('Press IME action button');
}
static pressBack() {
return new KeyboardActionResult('Press back');
}
static pressBackUnconditionally() {
return new KeyboardActionResult('Press back unconditionally');
}
static pressMenuKey() {
return new KeyboardActionResult('Press menu key');
}
static doubleClick() {
return new DoubleClickResult();
}
static longClick(duration) {
return new LongClickResult(duration);
}
static scrollTo(direction) {
return new ScrollToResult(direction);
}
static typeTextIntoFocusedView(stringToBeTyped) {
return new TypeTextResult(stringToBeTyped, true);
}
static typeText(stringToBeTyped) {
return new TypeTextResult(stringToBeTyped);
}
static openLinkWithText(linkText) {
return new OpenLinkResult('text', linkText);
}
static openLinkWithUri(uri) {
return new OpenLinkResult('uri', uri);
}
static repeatedlyUntil(action, desiredStateMatcher, maxAttempts) {
return new RepeatedlyUntilResult(action, desiredStateMatcher, maxAttempts);
}
static swipe(direction, speed) {
return new SwipeResult(direction, speed);
}
}
exports.ViewActions = ViewActions;
class ClearTextResult {
format(matcher) {
return (0, utils_1.concat)('Clear text on', matcher);
}
}
exports.ClearTextResult = ClearTextResult;
class PressKeyResult {
keyCode;
constructor(keyCode) {
this.keyCode = keyCode;
}
format(matcher) {
return (0, utils_1.concat)((0, utils_1.msg)(`Press key ${this.keyCode}`, { key_code: this.keyCode }), 'on', matcher);
}
}
exports.PressKeyResult = PressKeyResult;
class ReplaceTextResult {
text;
constructor(text) {
this.text = text;
}
format(matcher) {
return (0, utils_1.concat)((0, utils_1.msg)(`Replace text with "${this.text}"`, { text: this.text }), 'on', matcher);
}
}
exports.ReplaceTextResult = ReplaceTextResult;
class ClearGlobalAssertionsResult {
format() {
return (0, utils_1.msg)('Clear global assertions');
}
}
exports.ClearGlobalAssertionsResult = ClearGlobalAssertionsResult;
class ActionWithAssertionsResult {
action;
constructor(action) {
this.action = action;
}
format(matcher) {
return this.action.format(matcher);
}
}
exports.ActionWithAssertionsResult = ActionWithAssertionsResult;
class ClickResult {
inputDevice;
buttonState;
constructor(inputDevice, buttonState) {
this.inputDevice = inputDevice;
this.buttonState = buttonState;
}
format(matcher) {
return (0, utils_1.concat)((0, utils_1.msg)('Click', { input_device: this.inputDevice, button_state: this.buttonState }), 'on', matcher);
}
}
exports.ClickResult = ClickResult;
class SwipeResult {
direction;
speed;
constructor(direction, speed) {
this.direction = direction;
this.speed = speed;
}
format(matcher) {
return (0, utils_1.concat)((0, utils_1.msg)(`Swipe ${this.direction}`, { direction: this.direction, speed: this.speed }), 'on', matcher);
}
}
exports.SwipeResult = SwipeResult;
class KeyboardActionResult {
action;
constructor(action) {
this.action = action;
}
format() {
return (0, utils_1.msg)(this.action);
}
}
exports.KeyboardActionResult = KeyboardActionResult;
class DoubleClickResult {
format(matcher) {
return (0, utils_1.concat)('Double click on', matcher);
}
}
exports.DoubleClickResult = DoubleClickResult;
class LongClickResult {
duration;
constructor(duration) {
this.duration = duration;
}
format(matcher) {
return (0, utils_1.concat)((0, utils_1.msg)('Long click', { duration: this.duration }), 'on', matcher);
}
}
exports.LongClickResult = LongClickResult;
class ScrollToResult {
direction;
constructor(direction) {
this.direction = direction;
}
format(matcher) {
return (0, utils_1.concat)((0, utils_1.msg)('Scroll to', { direction: this.direction }), matcher);
}
}
exports.ScrollToResult = ScrollToResult;
class TypeTextResult {
text;
isFocused;
constructor(text, isFocused = false) {
this.text = text;
this.isFocused = isFocused;
}
format(matcher) {
return (0, utils_1.concat)('Type', (0, utils_1.msg)('text', { text: this.text }), this.isFocused ? 'into focused' : 'into', matcher);
}
}
exports.TypeTextResult = TypeTextResult;
class OpenLinkResult {
type;
value;
constructor(type, value) {
this.type = type;
this.value = value;
}
format() {
const param = this.type === 'text' ? { text: this.value } : { uri: this.value };
return (0, utils_1.msg)(`Open link with ${this.type} "${this.value}"`, param);
}
}
exports.OpenLinkResult = OpenLinkResult;
class RepeatedlyUntilResult {
action;
desiredStateMatcher;
maxAttempts;
constructor(action, desiredStateMatcher, maxAttempts) {
this.action = action;
this.desiredStateMatcher = desiredStateMatcher;
this.maxAttempts = maxAttempts;
}
format(matcher) {
return (0, utils_1.concat)('Repeatedly', this.action.format(matcher), 'until', this.desiredStateMatcher, (0, utils_1.msg)(`(max ${this.maxAttempts} attempts)`, { max_attempts: this.maxAttempts }));
}
}
exports.RepeatedlyUntilResult = RepeatedlyUntilResult;
//# sourceMappingURL=ViewActions.js.map