|
| 1 | +import { convertOnlyArrowFunctions } from "../only-arrow-functions"; |
| 2 | + |
| 3 | +describe(convertOnlyArrowFunctions, () => { |
| 4 | + test("conversion without arguments", () => { |
| 5 | + const result = convertOnlyArrowFunctions({ |
| 6 | + ruleArguments: [], |
| 7 | + }); |
| 8 | + |
| 9 | + expect(result).toEqual({ |
| 10 | + rules: [ |
| 11 | + { |
| 12 | + ruleName: "prefer-arrow/prefer-arrow-functions", |
| 13 | + }, |
| 14 | + ], |
| 15 | + plugins: ["prefer-arrow"], |
| 16 | + }); |
| 17 | + }); |
| 18 | + |
| 19 | + test("conversion with allow-declarations argument", () => { |
| 20 | + const result = convertOnlyArrowFunctions({ |
| 21 | + ruleArguments: ["allow-declarations"], |
| 22 | + }); |
| 23 | + |
| 24 | + expect(result).toEqual({ |
| 25 | + rules: [ |
| 26 | + { |
| 27 | + notices: ["ESLint does not support allowing standalone function declarations."], |
| 28 | + ruleName: "prefer-arrow/prefer-arrow-functions", |
| 29 | + }, |
| 30 | + ], |
| 31 | + plugins: ["prefer-arrow"], |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + test("conversion with allow-named-functions argument", () => { |
| 36 | + const result = convertOnlyArrowFunctions({ |
| 37 | + ruleArguments: ["allow-named-functions"], |
| 38 | + }); |
| 39 | + |
| 40 | + expect(result).toEqual({ |
| 41 | + rules: [ |
| 42 | + { |
| 43 | + notices: [ |
| 44 | + "ESLint does not support allowing named functions defined with the function keyword.", |
| 45 | + ], |
| 46 | + ruleName: "prefer-arrow/prefer-arrow-functions", |
| 47 | + }, |
| 48 | + ], |
| 49 | + plugins: ["prefer-arrow"], |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + test("conversion with all arguments", () => { |
| 54 | + const result = convertOnlyArrowFunctions({ |
| 55 | + ruleArguments: ["allow-declarations", "allow-named-functions"], |
| 56 | + }); |
| 57 | + |
| 58 | + expect(result).toEqual({ |
| 59 | + rules: [ |
| 60 | + { |
| 61 | + notices: [ |
| 62 | + "ESLint does not support allowing standalone function declarations.", |
| 63 | + "ESLint does not support allowing named functions defined with the function keyword.", |
| 64 | + ], |
| 65 | + ruleName: "prefer-arrow/prefer-arrow-functions", |
| 66 | + }, |
| 67 | + ], |
| 68 | + plugins: ["prefer-arrow"], |
| 69 | + }); |
| 70 | + }); |
| 71 | +}); |
0 commit comments