askui
Version:
Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on
24 lines (23 loc) • 771 B
JavaScript
import { InputEvent } from './input-event';
export class Action {
constructor(inputEvent, position, text, parameters = {}) {
this.inputEvent = inputEvent;
this.position = position;
this.text = text;
this.parameters = parameters;
}
static fromJson(action, resizeRatio = 1) {
return new Action(InputEvent[action.inputEvent], {
x: Math.round(action.position.x * resizeRatio),
y: Math.round(action.position.y * resizeRatio),
}, action.text, action.parameters ? action.parameters : {});
}
toJson() {
return {
inputEvent: this.inputEvent,
parameters: this.parameters,
position: this.position,
text: this.text,
};
}
}