|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const rule = require('../../../lib/rules/no-assigning-return-values'); |
| 4 | +const RuleTester = require('eslint').RuleTester; |
| 5 | + |
| 6 | +const ruleTester = new RuleTester(); |
| 7 | + |
| 8 | +const errors = [{ messageId: 'unexpected' }]; |
| 9 | +const parserOptions = { ecmaVersion: 6 }; |
| 10 | + |
| 11 | +ruleTester.run('no-assigning-return-values', rule, { |
| 12 | + valid: [ |
| 13 | + { code: 'var foo = true;', parserOptions }, |
| 14 | + { code: 'let foo = true;', parserOptions }, |
| 15 | + { code: 'const foo = true;', parserOptions }, |
| 16 | + { code: 'cy.get("foo");', parserOptions }, |
| 17 | + { code: 'cy.contains("foo").click();', parserOptions } |
| 18 | + ], |
| 19 | + |
| 20 | + invalid: [ |
| 21 | + { code: 'let a = cy.get("foo")', parserOptions, errors }, |
| 22 | + { code: 'const a = cy.get("foo")', parserOptions, errors }, |
| 23 | + { code: 'var a = cy.get("foo")', parserOptions, errors }, |
| 24 | + |
| 25 | + { code: 'let a = cy.contains("foo")', parserOptions, errors }, |
| 26 | + { code: 'let a = cy.window()', parserOptions, errors }, |
| 27 | + { code: 'let a = cy.wait("@something")', parserOptions, errors }, |
| 28 | + |
| 29 | + { code: 'let a = cy.contains("foo").click()', parserOptions, errors } |
| 30 | + ] |
| 31 | +}); |
0 commit comments