2019-05-01 18:09:29 +00:00
|
|
|
export default function(scenario, find, click) {
|
2019-02-21 13:05:05 +00:00
|
|
|
scenario
|
|
|
|
.when('I click "$selector"', function(selector) {
|
|
|
|
return click(selector);
|
|
|
|
})
|
|
|
|
// TODO: Probably nicer to think of better vocab than having the 'without " rule'
|
2019-05-01 18:09:29 +00:00
|
|
|
.when(['I click (?!")$property(?!")', 'I click $property on the $component'], function(
|
|
|
|
property,
|
|
|
|
component,
|
|
|
|
next
|
|
|
|
) {
|
2019-02-21 13:05:05 +00:00
|
|
|
try {
|
2019-05-01 18:09:29 +00:00
|
|
|
if (typeof component === 'string') {
|
|
|
|
property = `${component}.${property}`;
|
|
|
|
}
|
|
|
|
return find(property)();
|
2019-02-21 13:05:05 +00:00
|
|
|
} catch (e) {
|
2019-05-01 18:09:29 +00:00
|
|
|
throw e;
|
2019-02-21 13:05:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|