|
1 | 1 | /** |
2 | | - * @fileoverview Prefer toBeEmpty over checking innerHTML |
| 2 | + * @fileoverview Prefer toBeEmptyDOMElement over checking innerHTML |
3 | 3 | * @author Ben Monro |
4 | 4 | */ |
5 | 5 |
|
@@ -34,188 +34,188 @@ ruleTester.run("prefer-empty", rule, { |
34 | 34 | code: `expect(element.innerHTML === '').toBe(true)`, |
35 | 35 | errors: [ |
36 | 36 | { |
37 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 37 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
38 | 38 | }, |
39 | 39 | ], |
40 | | - output: `expect(element).toBeEmpty()`, |
| 40 | + output: `expect(element).toBeEmptyDOMElement()`, |
41 | 41 | }, |
42 | 42 | { |
43 | 43 | code: `expect(element.innerHTML !== '').toBe(true)`, |
44 | 44 | errors: [ |
45 | 45 | { |
46 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 46 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
47 | 47 | }, |
48 | 48 | ], |
49 | | - output: `expect(element).not.toBeEmpty()`, |
| 49 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
50 | 50 | }, |
51 | 51 | { |
52 | 52 | code: `expect(element.innerHTML === '').toBe(false)`, |
53 | 53 | errors: [ |
54 | 54 | { |
55 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 55 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
56 | 56 | }, |
57 | 57 | ], |
58 | | - output: `expect(element).not.toBeEmpty()`, |
| 58 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
59 | 59 | }, |
60 | 60 | { |
61 | 61 | code: `expect(element.innerHTML !== '').toBe(false)`, |
62 | 62 | errors: [ |
63 | 63 | { |
64 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 64 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
65 | 65 | }, |
66 | 66 | ], |
67 | | - output: `expect(element).toBeEmpty()`, |
| 67 | + output: `expect(element).toBeEmptyDOMElement()`, |
68 | 68 | }, |
69 | 69 | { |
70 | 70 | code: `expect(element.firstChild === null).toBe(true)`, |
71 | 71 | errors: [ |
72 | 72 | { |
73 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 73 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
74 | 74 | }, |
75 | 75 | ], |
76 | | - output: `expect(element).toBeEmpty()`, |
| 76 | + output: `expect(element).toBeEmptyDOMElement()`, |
77 | 77 | }, |
78 | 78 | { |
79 | 79 | code: `expect(element.firstChild !== null).toBe(false)`, |
80 | 80 | errors: [ |
81 | 81 | { |
82 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 82 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
83 | 83 | }, |
84 | 84 | ], |
85 | | - output: `expect(element).toBeEmpty()`, |
| 85 | + output: `expect(element).toBeEmptyDOMElement()`, |
86 | 86 | }, |
87 | 87 | { |
88 | 88 | code: `expect(element.firstChild === null).toBe(false)`, |
89 | 89 | errors: [ |
90 | 90 | { |
91 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 91 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
92 | 92 | }, |
93 | 93 | ], |
94 | | - output: `expect(element).not.toBeEmpty()`, |
| 94 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
95 | 95 | }, |
96 | 96 | { |
97 | 97 | code: `expect(element.innerHTML).toBe('')`, |
98 | 98 | errors: [ |
99 | 99 | { |
100 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 100 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
101 | 101 | }, |
102 | 102 | ], |
103 | | - output: `expect(element).toBeEmpty()`, |
| 103 | + output: `expect(element).toBeEmptyDOMElement()`, |
104 | 104 | }, |
105 | 105 |
|
106 | 106 | { |
107 | 107 | code: `expect(element.innerHTML).toBe(null)`, |
108 | 108 | errors: [ |
109 | 109 | { |
110 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 110 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
111 | 111 | }, |
112 | 112 | ], |
113 | | - output: `expect(element).toBeEmpty()`, |
| 113 | + output: `expect(element).toBeEmptyDOMElement()`, |
114 | 114 | }, |
115 | 115 | { |
116 | 116 | code: `expect(element.innerHTML).not.toBe(null)`, |
117 | 117 | errors: [ |
118 | 118 | { |
119 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 119 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
120 | 120 | }, |
121 | 121 | ], |
122 | | - output: `expect(element).not.toBeEmpty()`, |
| 122 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
123 | 123 | }, |
124 | 124 |
|
125 | 125 | { |
126 | 126 | code: `expect(element.innerHTML).not.toBe('')`, |
127 | 127 | errors: [ |
128 | 128 | { |
129 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 129 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
130 | 130 | }, |
131 | 131 | ], |
132 | | - output: `expect(element).not.toBeEmpty()`, |
| 132 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
133 | 133 | }, |
134 | 134 |
|
135 | 135 | { |
136 | 136 | code: `expect(element.firstChild).toBeNull()`, |
137 | 137 | errors: [ |
138 | 138 | { |
139 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 139 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
140 | 140 | }, |
141 | 141 | ], |
142 | | - output: `expect(element).toBeEmpty()`, |
| 142 | + output: `expect(element).toBeEmptyDOMElement()`, |
143 | 143 | }, |
144 | 144 | { |
145 | 145 | code: `expect(element.firstChild).toBe(null)`, |
146 | 146 | errors: [ |
147 | 147 | { |
148 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 148 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
149 | 149 | }, |
150 | 150 | ], |
151 | | - output: `expect(element).toBeEmpty()`, |
| 151 | + output: `expect(element).toBeEmptyDOMElement()`, |
152 | 152 | }, |
153 | 153 | { |
154 | 154 | code: `expect(element.firstChild).not.toBe(null)`, |
155 | 155 | errors: [ |
156 | 156 | { |
157 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 157 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
158 | 158 | }, |
159 | 159 | ], |
160 | | - output: `expect(element).not.toBeEmpty()`, |
| 160 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
161 | 161 | }, |
162 | 162 |
|
163 | 163 | { |
164 | 164 | code: `expect(element.firstChild).not.toBeNull()`, |
165 | 165 | errors: [ |
166 | 166 | { |
167 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 167 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
168 | 168 | }, |
169 | 169 | ], |
170 | | - output: `expect(element).not.toBeEmpty()`, |
| 170 | + output: `expect(element).not.toBeEmptyDOMElement()`, |
171 | 171 | }, |
172 | 172 | { |
173 | 173 | code: `expect(getByText('foo').innerHTML).toBe('')`, |
174 | 174 | errors: [ |
175 | 175 | { |
176 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 176 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
177 | 177 | }, |
178 | 178 | ], |
179 | | - output: `expect(getByText('foo')).toBeEmpty()`, |
| 179 | + output: `expect(getByText('foo')).toBeEmptyDOMElement()`, |
180 | 180 | }, |
181 | 181 |
|
182 | 182 | { |
183 | 183 | code: `expect(getByText('foo').innerHTML).toStrictEqual('')`, |
184 | 184 | errors: [ |
185 | 185 | { |
186 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 186 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
187 | 187 | }, |
188 | 188 | ], |
189 | | - output: `expect(getByText('foo')).toBeEmpty()`, |
| 189 | + output: `expect(getByText('foo')).toBeEmptyDOMElement()`, |
190 | 190 | }, |
191 | 191 |
|
192 | 192 | { |
193 | 193 | code: `expect(getByText('foo').innerHTML).toStrictEqual(null)`, |
194 | 194 | errors: [ |
195 | 195 | { |
196 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 196 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
197 | 197 | }, |
198 | 198 | ], |
199 | | - output: `expect(getByText('foo')).toBeEmpty()`, |
| 199 | + output: `expect(getByText('foo')).toBeEmptyDOMElement()`, |
200 | 200 | }, |
201 | 201 |
|
202 | 202 | { |
203 | 203 | code: `expect(getByText('foo').firstChild).toBe(null)`, |
204 | 204 | errors: [ |
205 | 205 | { |
206 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 206 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
207 | 207 | }, |
208 | 208 | ], |
209 | | - output: `expect(getByText('foo')).toBeEmpty()`, |
| 209 | + output: `expect(getByText('foo')).toBeEmptyDOMElement()`, |
210 | 210 | }, |
211 | 211 | { |
212 | 212 | code: `expect(getByText('foo').firstChild).not.toBe(null)`, |
213 | 213 | errors: [ |
214 | 214 | { |
215 | | - message: "Use toBeEmpty instead of checking inner html.", |
| 215 | + message: "Use toBeEmptyDOMElement instead of checking inner html.", |
216 | 216 | }, |
217 | 217 | ], |
218 | | - output: `expect(getByText('foo')).not.toBeEmpty()`, |
| 218 | + output: `expect(getByText('foo')).not.toBeEmptyDOMElement()`, |
219 | 219 | }, |
220 | 220 | ], |
221 | 221 | }); |
0 commit comments