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