detox-allure2-adapter
Version:
Detox adapter for jest-allure2-reporter
35 lines • 3.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatAction = void 0;
const utils_1 = require("../../utils");
const expectation_formatters_1 = require("./expectation-formatters");
const predicate_formatters_1 = require("./predicate-formatters");
const actionFormatters = {
tap: ({ predicate }) => (0, utils_1.concat)('Tap', (0, predicate_formatters_1.formatPredicate)(predicate)),
longPress: ({ predicate, params: [duration] }) => (0, utils_1.concat)((0, utils_1.msg)('Long press', { duration }), (0, predicate_formatters_1.formatPredicate)(predicate)),
scroll: ({ predicate, params: [distance, direction], while: whileCondition }) => {
return (0, utils_1.concat)((0, utils_1.msg)(`Scroll ${direction || 'somewhere'} on`, { direction, distance }), (0, predicate_formatters_1.formatPredicate)(predicate), (0, expectation_formatters_1.formatWhileCondition)(whileCondition));
},
scrollTo: ({ predicate, params: [edge, normalizedX, normalizedY] }) => (0, utils_1.concat)((0, utils_1.msg)(`Scroll to ${edge || 'edge'}`, {
edge,
...(normalizedX !== undefined && { x: normalizedX, y: normalizedY }),
}), 'on', (0, predicate_formatters_1.formatPredicate)(predicate)),
replaceText: ({ predicate, params: [text] }) => (0, utils_1.concat)((0, utils_1.msg)('Replace text in', { text }), (0, predicate_formatters_1.formatPredicate)(predicate)),
typeText: ({ predicate, params: [text] }) => (0, utils_1.concat)((0, utils_1.msg)('Type text in', { text }), (0, predicate_formatters_1.formatPredicate)(predicate)),
accessibilityAction: ({ predicate, params: [action] }) => (0, utils_1.concat)((0, utils_1.msg)(`Activate a11y ${action ? `"${action}"` : 'action'} on`, { action }), (0, predicate_formatters_1.formatPredicate)(predicate)),
setDatePickerDate: ({ predicate, params: [date, format] }) => (0, utils_1.concat)('Set date picker', (0, predicate_formatters_1.formatPredicate)(predicate), (0, utils_1.msg)(`${date}`, { date, format })),
setColumnToValue: ({ predicate, params: [column, value] }) => (0, utils_1.concat)('Set', (0, predicate_formatters_1.formatPredicate)(predicate), 'column', (0, utils_1.msg)(`[${column}]`, { column }), 'to:', (0, utils_1.msg)(`${(0, utils_1.truncate)(value)}`, { value })),
multiTap: ({ predicate, params: [count] }) => (0, utils_1.concat)((0, utils_1.msg)(`Tap ${count} times on`, { count }), (0, predicate_formatters_1.formatPredicate)(predicate)),
swipe: ({ predicate, params: [direction, speed, amount] }) => (0, utils_1.concat)((0, utils_1.msg)(`Swipe ${direction} on`, {
direction,
speed,
amount,
}), (0, predicate_formatters_1.formatPredicate)(predicate)),
};
const formatAction = (action) => {
const formatter = actionFormatters[action.action];
const safeAction = action?.params ? action : { ...action, params: [] };
return formatter ? formatter(safeAction) : null;
};
exports.formatAction = formatAction;
//# sourceMappingURL=action-formatters.js.map