|
1 | | -import { generateRecommendedConfig, rules } from "../"; |
| 1 | +import plugin, { configs, rules } from "../"; |
| 2 | + |
| 3 | +it("includes the configs and rules on the plugin", () => { |
| 4 | + expect(plugin).toHaveProperty("configs", configs); |
| 5 | + expect(plugin).toHaveProperty("rules", rules); |
| 6 | +}); |
2 | 7 |
|
3 | 8 | it("should have all the rules", () => { |
4 | | - expect(Object.keys(rules).length).toBeGreaterThan(0); |
| 9 | + expect(Object.keys(rules)).toHaveLength(11); |
5 | 10 | }); |
6 | 11 |
|
7 | | -it.each(Object.keys(rules))("%s should export required fields", (ruleName) => { |
8 | | - const rule = rules[ruleName]; |
9 | | - expect(rule).toHaveProperty("create", expect.any(Function)); |
10 | | - expect(rule.meta.docs.url).not.toBe(""); |
11 | | - expect(rule.meta.docs.category).toBe("Best Practices"); |
12 | | - expect(rule.meta.docs.description).not.toBe(""); |
| 12 | +it.each(Object.entries(rules))( |
| 13 | + "%s should export required fields", |
| 14 | + (name, rule) => { |
| 15 | + expect(rule).toHaveProperty("create", expect.any(Function)); |
| 16 | + expect(rule.meta.docs.url).not.toBe(""); |
| 17 | + expect(rule.meta.docs.category).toBe("Best Practices"); |
| 18 | + expect(rule.meta.docs.description).not.toBe(""); |
| 19 | + } |
| 20 | +); |
| 21 | + |
| 22 | +it("has the expected recommended config", () => { |
| 23 | + expect(configs.recommended).toMatchInlineSnapshot(` |
| 24 | + Object { |
| 25 | + plugins: Array [ |
| 26 | + jest-dom, |
| 27 | + ], |
| 28 | + rules: Object { |
| 29 | + jest-dom/prefer-checked: error, |
| 30 | + jest-dom/prefer-empty: error, |
| 31 | + jest-dom/prefer-enabled-disabled: error, |
| 32 | + jest-dom/prefer-focus: error, |
| 33 | + jest-dom/prefer-in-document: error, |
| 34 | + jest-dom/prefer-required: error, |
| 35 | + jest-dom/prefer-to-have-attribute: error, |
| 36 | + jest-dom/prefer-to-have-class: error, |
| 37 | + jest-dom/prefer-to-have-style: error, |
| 38 | + jest-dom/prefer-to-have-text-content: error, |
| 39 | + jest-dom/prefer-to-have-value: error, |
| 40 | + }, |
| 41 | + } |
| 42 | + `); |
13 | 43 | }); |
14 | 44 |
|
15 | | -it("should have a recommended config with recommended rules", () => { |
16 | | - expect( |
17 | | - generateRecommendedConfig({ |
18 | | - good: { meta: { docs: { recommended: true } } }, |
19 | | - bad: { meta: { docs: { recommended: false } } }, |
20 | | - }) |
21 | | - ).toEqual({ "jest-dom/good": "error" }); |
| 45 | +it("has the expected recommended flat config", () => { |
| 46 | + const expectJestDomPlugin = expect.objectContaining({ |
| 47 | + meta: { |
| 48 | + name: "eslint-plugin-jest-dom", |
| 49 | + version: expect.any(String), |
| 50 | + }, |
| 51 | + }); |
| 52 | + |
| 53 | + expect(configs["flat/recommended"]).toMatchInlineSnapshot( |
| 54 | + { plugins: { "jest-dom": expectJestDomPlugin } }, |
| 55 | + ` |
| 56 | + Object { |
| 57 | + plugins: Object { |
| 58 | + jest-dom: ObjectContaining { |
| 59 | + meta: Object { |
| 60 | + name: eslint-plugin-jest-dom, |
| 61 | + version: Any<String>, |
| 62 | + }, |
| 63 | + }, |
| 64 | + }, |
| 65 | + rules: Object { |
| 66 | + jest-dom/prefer-checked: error, |
| 67 | + jest-dom/prefer-empty: error, |
| 68 | + jest-dom/prefer-enabled-disabled: error, |
| 69 | + jest-dom/prefer-focus: error, |
| 70 | + jest-dom/prefer-in-document: error, |
| 71 | + jest-dom/prefer-required: error, |
| 72 | + jest-dom/prefer-to-have-attribute: error, |
| 73 | + jest-dom/prefer-to-have-class: error, |
| 74 | + jest-dom/prefer-to-have-style: error, |
| 75 | + jest-dom/prefer-to-have-text-content: error, |
| 76 | + jest-dom/prefer-to-have-value: error, |
| 77 | + }, |
| 78 | + } |
| 79 | + ` |
| 80 | + ); |
22 | 81 | }); |
0 commit comments