Skip to content

Commit

Permalink
Merge pull request #38 from LarsHassler/feat/click-action
Browse files Browse the repository at this point in the history
feat(main): added click action
  • Loading branch information
LarsHassler committed Feb 16, 2017
2 parents 703431d + 6cc1bdc commit 5a3e8c1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ into separate test suites.
## Available Actions
- [hover](#hover)
- [focus](#focus)
- [click](#click)
- [sendKeys](#sendKeys)

## Options for all patterns
Expand Down Expand Up @@ -65,6 +66,10 @@ See #22 for more details.

A particular element within a pattern will be tested while it is focused.

## click

A particular element within a pattern will be clicked and then tested.

## sendKeys

Sends keyboard events an element before it beeing tested.
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ PatternlabToNode.prototype.parseAction = function(pattern) {
else if (action.action === 'focus') {
action.steps = '.focus(this.element)';
}
else if (action.action === 'click') {
action.steps = '.click(this.element)';
}
else if (action.action === 'sendKeys') {
if (!action.keys) {
throw new Error(
Expand Down
28 changes: 28 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ describe('main - ', () => {
shouldAddCorrectStepsForFocus
);

it('should add correct steps for click',
shouldAddCorrectStepsForClick
);

it("should add correct steps for delay",
shouldAddCorrectStepsForDelay
);
Expand Down Expand Up @@ -1776,6 +1780,30 @@ describe('main - ', () => {
}


function shouldAddCorrectStepsForClick(done) {
setUpFsMock({
"config.json": path.resolve(__dirname, 'patternlab-to-geminiConfigs/actionClicked.json'),
'dummyhtml/patterns.html': __dirname + '/dummyhtml/patterns.html'
});
var instanceToTest = new patternlabToNode(
'config.json'
);
setUpPatternlabResponse(
'http://localhost:3000',
'dummyhtml/patterns.html'
);
instanceToTest.getPatternsConfiguration()
.then((patternConfig) => {
asserts.assertEquals(
'wrong steps for action',
'.click(this.element)',
patternConfig.patterns['pattern-1'].actions[0].steps
);
})
.then(done, done);
}


function shouldAddCorrectStepsForDelay(done) {
setUpFsMock({
"config.json": path.resolve(__dirname, 'patternlab-to-geminiConfigs/actionFocusWithDelay.json'),
Expand Down
18 changes: 18 additions & 0 deletions test/patternlab-to-geminiConfigs/actionClicked.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"screenSizes": {
"desktop": {
"width": 1440,
"height": 900
}
},
"patterns": {
"pattern-1": {
"actions": [
{
"action": "click",
"name": "action 1"
}
]
}
}
}

0 comments on commit 5a3e8c1

Please sign in to comment.