UNPKG

detox-allure2-adapter

Version:
222 lines 8.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LongPressAndDragResult = exports.TapAtLocationResult = exports.MultiClickResult = exports.TakeViewScreenshotResult = exports.SwipeInDirectionResult = exports.SetDatePickerDateResult = exports.ScrollToIndexResult = exports.ScrollToEdgeResult = exports.ScrollInDirectionStaleAtEdgeResult = exports.ScrollInDirectionResult = exports.LongPressResult = exports.GetAttributesResult = exports.AdjustSliderToPositionResult = exports.AccessibilityActionResult = void 0; const utils_1 = require("../../utils"); class AccessibilityActionResult { actionName; constructor(actionName) { this.actionName = actionName; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Activate accessibility action "${this.actionName}"`, { action: this.actionName }), 'on', matcher); } } exports.AccessibilityActionResult = AccessibilityActionResult; class AdjustSliderToPositionResult { position; constructor(position) { this.position = position; } format(matcher) { return (0, utils_1.concat)('Adjust slider', matcher, (0, utils_1.msg)(`to position ${this.position}`, { position: this.position })); } } exports.AdjustSliderToPositionResult = AdjustSliderToPositionResult; class GetAttributesResult { format(matcher) { return (0, utils_1.concat)('Get attributes of', matcher); } } exports.GetAttributesResult = GetAttributesResult; class LongPressResult { x; y; duration; constructor(x, y, duration) { this.x = x; this.y = y; this.duration = duration; } format(matcher) { const point = this.x != null || this.y != null ? (0, utils_1.msg)(`at (${this.x}, ${this.y})`, { x: this.x, y: this.y }) : null; return (0, utils_1.concat)((0, utils_1.msg)('Long press', { duration: this.duration }), point, 'on', matcher); } } exports.LongPressResult = LongPressResult; class ScrollInDirectionResult { amountInDP; startOffsetPercentX; startOffsetPercentY; static DIRECTIONS = ['left', 'right', 'up', 'down']; direction; constructor(direction, amountInDP, startOffsetPercentX, startOffsetPercentY) { this.amountInDP = amountInDP; this.startOffsetPercentX = startOffsetPercentX; this.startOffsetPercentY = startOffsetPercentY; this.direction = typeof direction === 'string' ? direction : ScrollInDirectionResult.DIRECTIONS[direction - 1]; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Scroll ${this.direction}`, { direction: this.direction, amount: this.amountInDP, start_x: this.startOffsetPercentX, start_y: this.startOffsetPercentY, }), 'on', matcher); } } exports.ScrollInDirectionResult = ScrollInDirectionResult; class ScrollInDirectionStaleAtEdgeResult { amountInDP; startOffsetPercentX; startOffsetPercentY; static DIRECTIONS = ['left', 'right', 'top', 'bottom']; direction; constructor(direction, amountInDP, startOffsetPercentX, startOffsetPercentY) { this.amountInDP = amountInDP; this.startOffsetPercentX = startOffsetPercentX; this.startOffsetPercentY = startOffsetPercentY; this.direction = ScrollInDirectionStaleAtEdgeResult.DIRECTIONS[direction - 1]; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Scroll ${this.direction} until stale at edge`, { direction: this.direction, amount: this.amountInDP, start_x: this.startOffsetPercentX, start_y: this.startOffsetPercentY, }), 'on', matcher); } } exports.ScrollInDirectionStaleAtEdgeResult = ScrollInDirectionStaleAtEdgeResult; class ScrollToEdgeResult { edge; startOffsetPercentX; startOffsetPercentY; constructor(edge, startOffsetPercentX, startOffsetPercentY) { this.edge = edge; this.startOffsetPercentX = startOffsetPercentX; this.startOffsetPercentY = startOffsetPercentY; } format(matcher) { const edgeDescription = this.edge === 1 ? 'bottom' : 'top'; return (0, utils_1.concat)((0, utils_1.msg)(`Scroll to ${edgeDescription}`, { edge: this.edge, start_x: this.startOffsetPercentX, start_y: this.startOffsetPercentY, }), 'on', matcher); } } exports.ScrollToEdgeResult = ScrollToEdgeResult; class ScrollToIndexResult { index; constructor(index) { this.index = index; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Scroll to index ${this.index}`, { index: this.index }), 'on', matcher); } } exports.ScrollToIndexResult = ScrollToIndexResult; class SetDatePickerDateResult { dateString; formatString; constructor(dateString, formatString) { this.dateString = dateString; this.formatString = formatString; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Set date to "${this.dateString}"`, { date: this.dateString, format: this.formatString, }), 'on', matcher); } } exports.SetDatePickerDateResult = SetDatePickerDateResult; class SwipeInDirectionResult { direction; fast; normalizedOffset; normalizedStartingPointX; normalizedStartingPointY; constructor(direction, fast, normalizedOffset, normalizedStartingPointX, normalizedStartingPointY) { this.direction = direction; this.fast = fast; this.normalizedOffset = normalizedOffset; this.normalizedStartingPointX = normalizedStartingPointX; this.normalizedStartingPointY = normalizedStartingPointY; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Swipe ${this.direction}${this.fast ? ' fast' : ''}`, { direction: this.direction, fast: this.fast, offset: this.normalizedOffset, start_x: this.normalizedStartingPointX, start_y: this.normalizedStartingPointY, }), 'on', matcher); } } exports.SwipeInDirectionResult = SwipeInDirectionResult; class TakeViewScreenshotResult { format(matcher) { return (0, utils_1.concat)('Take screenshot of', matcher); } } exports.TakeViewScreenshotResult = TakeViewScreenshotResult; class MultiClickResult { times; constructor(times) { this.times = times; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Tap ${this.times} times`, { times: this.times }), 'on', matcher); } } exports.MultiClickResult = MultiClickResult; class TapAtLocationResult { x; y; constructor(x, y) { this.x = x; this.y = y; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Tap at (${this.x}, ${this.y})`, { x: this.x, y: this.y }), 'on', matcher); } } exports.TapAtLocationResult = TapAtLocationResult; class LongPressAndDragResult { duration; normalizedPositionX; normalizedPositionY; targetElement; normalizedTargetPositionX; normalizedTargetPositionY; isFast; holdDuration; constructor(duration, normalizedPositionX, normalizedPositionY, targetElement, normalizedTargetPositionX, normalizedTargetPositionY, isFast, holdDuration) { this.duration = duration; this.normalizedPositionX = normalizedPositionX; this.normalizedPositionY = normalizedPositionY; this.targetElement = targetElement; this.normalizedTargetPositionX = normalizedTargetPositionX; this.normalizedTargetPositionY = normalizedTargetPositionY; this.isFast = isFast; this.holdDuration = holdDuration; } format(matcher) { return (0, utils_1.concat)((0, utils_1.msg)(`Long press for ${this.duration}ms`, { duration: this.duration, start_x: this.normalizedPositionX, start_y: this.normalizedPositionY, fast: this.isFast, hold_duration: this.holdDuration, }), 'on', matcher, 'and drag to', this.targetElement, (0, utils_1.msg)(`at (${this.normalizedTargetPositionX}, ${this.normalizedTargetPositionY})`, { target_x: this.normalizedTargetPositionX, target_y: this.normalizedTargetPositionY, })); } } exports.LongPressAndDragResult = LongPressAndDragResult; //# sourceMappingURL=DetoxActionResults.js.map