|
| 1 | +'use strict' |
| 2 | + |
| 3 | +//------------------------------------------------------------------------------ |
| 4 | +// Requirements |
| 5 | +//------------------------------------------------------------------------------ |
| 6 | + |
| 7 | +const rule = require('../../../lib/rules/no-force') |
| 8 | + |
| 9 | +const RuleTester = require('eslint').RuleTester |
| 10 | + |
| 11 | +const errors = [{ messageId: 'unexpected' }] |
| 12 | +const parserOptions = { ecmaVersion: 2018 } |
| 13 | + |
| 14 | +//------------------------------------------------------------------------------ |
| 15 | +// Tests |
| 16 | +//------------------------------------------------------------------------------ |
| 17 | + |
| 18 | +let ruleTester = new RuleTester() |
| 19 | + |
| 20 | +ruleTester.run('no-force', rule, { |
| 21 | + |
| 22 | + valid: [ |
| 23 | + { code: `cy.get('button').click()`, parserOptions }, |
| 24 | + { code: `cy.get('button').click({multiple: true})`, parserOptions }, |
| 25 | + { code: `cy.get('button').dblclick()`, parserOptions }, |
| 26 | + { code: `cy.get('input').type('somth')`, parserOptions }, |
| 27 | + { code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions }, |
| 28 | + { code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions }, |
| 29 | + { code: `cy.get('input').rightclick({anyoption: true})`, parserOptions }, |
| 30 | + { code: `cy.get('input').check()`, parserOptions }, |
| 31 | + { code: `cy.get('input').select()`, parserOptions }, |
| 32 | + { code: `cy.get('input').focus()`, parserOptions }, |
| 33 | + { code: `cy.document().trigger("keydown", { ...event })`, parserOptions }, |
| 34 | + ], |
| 35 | + |
| 36 | + invalid: [ |
| 37 | + { code: `cy.get('button').click({force: true})`, parserOptions, errors }, |
| 38 | + { code: `cy.get('button').dblclick({force: true})`, parserOptions, errors }, |
| 39 | + { code: `cy.get('input').type('somth', {force: true})`, parserOptions, errors }, |
| 40 | + { code: `cy.get('div').find('.foo').type('somth', {force: true})`, parserOptions, errors }, |
| 41 | + { code: `cy.get('div').find('.foo').find('.bar').click({force: true})`, parserOptions, errors }, |
| 42 | + { code: `cy.get('div').find('.foo').find('.bar').trigger('change', {force: true})`, parserOptions, errors }, |
| 43 | + { code: `cy.get('input').trigger('click', {force: true})`, parserOptions, errors }, |
| 44 | + { code: `cy.get('input').rightclick({force: true})`, parserOptions, errors }, |
| 45 | + { code: `cy.get('input').check({force: true})`, parserOptions, errors }, |
| 46 | + { code: `cy.get('input').select({force: true})`, parserOptions, errors }, |
| 47 | + { code: `cy.get('input').focus({force: true})`, parserOptions, errors }, |
| 48 | + ], |
| 49 | +}) |
0 commit comments