Skip to content

Commit

Permalink
Add test scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao committed Oct 7, 2021
1 parent 35a8be2 commit b5c8db8
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions test/unit/rules/no-action-on-submit-button-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,45 @@ generateRuleTests({
config: true,

good: [
// valid "button" type
// valid buttons with "button" type
'<button type="button" />',
'<button type="button" {{action "handleClick"}} />',
'<button type="button" {{action this.handleClick"}} />',
'<button type="button" {{action this.handleClick" on="click"}} />',
'<button type="button" {{action this.handleMouseover" on="mouseOver"}} />',
'<button type="button" {{on "click" this.handleClick}} />',
'<button type="button" {{on "mouseover" this.handleMouseover}} />',

// valid "submit" type
// valid buttons with "submit" type
'<button />',
'<button type="submit" />',
'<button type="submit" {{action this.handleMouseover" on="mouseOver"}} />',
'<button type="submit" {{on "mouseover" this.handleMouseover}} />',

// valid div elements
'<div/>',
'<div></div>',
'<div type="submit"></div>',
'<div type="submit" {{action "handleClick"}}></div>',
'<div type="submit" {{action this.handleClick"}}></div>',
'<div type="submit" {{on "click" this.handleClick}}></div>',
],

bad: [
{
template: '<button {{action "handleClick"}} />',
template: '<button {{action this.handleClick}} />',

result: {
message: ERROR_MESSAGE,
source: '<button {{action "handleClick"}} />',
source: '<button {{action this.handleClick}} />',
line: 1,
column: 0,
},
},
{
template: '<button {{action this.handleClick" on="click"}}/>',

result: {
message: ERROR_MESSAGE,
source: '<button {{action this.handleClick" on="click"}}/>',
line: 1,
column: 0,
},
Expand All @@ -48,11 +63,21 @@ generateRuleTests({
},
},
{
template: '<button type="submit" {{action "handleClick"}} />',
template: '<button type="submit" {{action this.handleClick}} />',

result: {
message: ERROR_MESSAGE,
source: '<button type="submit" {{action this.handleClick}} />',
line: 1,
column: 0,
},
},
{
template: '<button type="submit" {{action this.handleClick" on="click"}} />',

result: {
message: ERROR_MESSAGE,
source: '<button type="submit" {{action "handleClick"}} />',
source: '<button type="submit" {{action this.handleClick" on="click"}} />',
line: 1,
column: 0,
},
Expand Down

0 comments on commit b5c8db8

Please sign in to comment.