Skip to content

Commit aa88e2d

Browse files
committed
Added test to check if statement
1 parent d1088f3 commit aa88e2d

21 files changed

Lines changed: 1551 additions & 508 deletions

packages/lint/src/lib/test-templates.ts

Lines changed: 735 additions & 12 deletions
Large diffs are not rendered by default.

packages/lint/src/tests/actor-assertion-method-required.test.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { test } from "node:test";
22
import { properties, RULE_IDS } from "../lib/const.ts";
33
import { actorPropertyRequired } from "../lib/messages.ts";
4+
import { createKeyRequiredEdgeCaseTests } from "../lib/test-templates.ts";
45
import lintTest from "../lib/test.ts";
56
import * as rule from "../rules/actor-assertion-method-required.ts";
67

@@ -201,3 +202,63 @@ test(
201202
expectedError: actorPropertyRequired(properties.assertionMethod),
202203
}),
203204
);
205+
206+
// Edge case tests
207+
const config = { rule, ruleName };
208+
const edgeCases = createKeyRequiredEdgeCaseTests("assertionMethod", config);
209+
test(
210+
`${ruleName}: ✅ Edge - ternary with property in both branches`,
211+
edgeCases["ternary with property in both branches"],
212+
);
213+
test(
214+
`${ruleName}: ❌ Edge - ternary missing property in consequent`,
215+
edgeCases["ternary missing property in consequent"],
216+
);
217+
test(
218+
`${ruleName}: ❌ Edge - ternary missing property in alternate`,
219+
edgeCases["ternary missing property in alternate"],
220+
);
221+
test(
222+
`${ruleName}: ❌ Edge - ternary missing property in both branches`,
223+
edgeCases["ternary missing property in both branches"],
224+
);
225+
test(
226+
`${ruleName}: ✅ Edge - nested ternary with property`,
227+
edgeCases["nested ternary with property"],
228+
);
229+
test(
230+
`${ruleName}: ✅ Edge - if/else with property in both branches`,
231+
edgeCases["if else with property in both branches"],
232+
);
233+
test(
234+
`${ruleName}: ❌ Edge - if/else missing property in if block`,
235+
edgeCases["if else missing property in if block"],
236+
);
237+
test(
238+
`${ruleName}: ❌ Edge - if/else missing property in else block`,
239+
edgeCases["if else missing property in else block"],
240+
);
241+
test(
242+
`${ruleName}: ❌ Edge - if/else missing property in both blocks`,
243+
edgeCases["if else missing property in both blocks"],
244+
);
245+
test(
246+
`${ruleName}: ✅ Edge - nested if with property`,
247+
edgeCases["nested if with property"],
248+
);
249+
test(
250+
`${ruleName}: ✅ Edge - if else if else with property in all branches`,
251+
edgeCases["if else if else with property in all branches"],
252+
);
253+
test(
254+
`${ruleName}: ❌ Edge - if else if else missing property in else if`,
255+
edgeCases["if else if else missing property in else if"],
256+
);
257+
test(
258+
`${ruleName}: ✅ Edge - if else if with final return property in all paths`,
259+
edgeCases["if else if with final return property in all paths"],
260+
);
261+
test(
262+
`${ruleName}: ❌ Edge - if else if with final return missing property in final return`,
263+
edgeCases["if else if with final return missing property in final return"],
264+
);

packages/lint/src/tests/actor-featured-property-mismatch.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,39 @@ test(
4949
`${ruleName}: ✅ Edge - nested ternary with correct getter`,
5050
edgeCases["nested ternary with correct getter"],
5151
);
52+
test(
53+
`${ruleName}: ✅ Edge - if/else with correct getter in both branches`,
54+
edgeCases["if else with correct getter in both branches"],
55+
);
56+
test(
57+
`${ruleName}: ❌ Edge - if/else with wrong getter in if block`,
58+
edgeCases["if else with wrong getter in if block"],
59+
);
60+
test(
61+
`${ruleName}: ❌ Edge - if/else with wrong getter in else block`,
62+
edgeCases["if else with wrong getter in else block"],
63+
);
64+
test(
65+
`${ruleName}: ❌ Edge - if/else with wrong getter in both blocks`,
66+
edgeCases["if else with wrong getter in both blocks"],
67+
);
68+
test(
69+
`${ruleName}: ✅ Edge - nested if with correct getter`,
70+
edgeCases["nested if with correct getter"],
71+
);
72+
test(
73+
`${ruleName}: ✅ Edge - if else if else with correct getter in all branches`,
74+
edgeCases["if else if else with correct getter in all branches"],
75+
);
76+
test(
77+
`${ruleName}: ❌ Edge - if else if else with wrong getter in else if`,
78+
edgeCases["if else if else with wrong getter in else if"],
79+
);
80+
test(
81+
`${ruleName}: ✅ Edge - if else if with final return correct getter in all paths`,
82+
edgeCases["if else if with final return correct getter in all paths"],
83+
);
84+
test(
85+
`${ruleName}: ❌ Edge - if else if with final return wrong getter in final return`,
86+
edgeCases["if else if with final return wrong getter in final return"],
87+
);

packages/lint/src/tests/actor-featured-property-required.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,39 @@ test(
7979
`${ruleName}: ✅ Edge - nested ternary with property`,
8080
edgeCases["nested ternary with property"],
8181
);
82+
test(
83+
`${ruleName}: ✅ Edge - if/else with property in both branches`,
84+
edgeCases["if else with property in both branches"],
85+
);
86+
test(
87+
`${ruleName}: ❌ Edge - if/else missing property in if block`,
88+
edgeCases["if else missing property in if block"],
89+
);
90+
test(
91+
`${ruleName}: ❌ Edge - if/else missing property in else block`,
92+
edgeCases["if else missing property in else block"],
93+
);
94+
test(
95+
`${ruleName}: ❌ Edge - if/else missing property in both blocks`,
96+
edgeCases["if else missing property in both blocks"],
97+
);
98+
test(
99+
`${ruleName}: ✅ Edge - nested if with property`,
100+
edgeCases["nested if with property"],
101+
);
102+
test(
103+
`${ruleName}: ✅ Edge - if else if else with featured in all branches`,
104+
edgeCases["if else if else with property in all branches"],
105+
);
106+
test(
107+
`${ruleName}: ❌ Edge - if else if else missing featured in else if`,
108+
edgeCases["if else if else missing property in else if"],
109+
);
110+
test(
111+
`${ruleName}: ✅ Edge - if else if with final return featured in all paths`,
112+
edgeCases["if else if with final return property in all paths"],
113+
);
114+
test(
115+
`${ruleName}: ❌ Edge - if else if with final return missing featured in final return`,
116+
edgeCases["if else if with final return missing property in final return"],
117+
);

packages/lint/src/tests/actor-featured-tags-property-mismatch.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,39 @@ test(
4949
`${ruleName}: ✅ Edge - nested ternary with correct getter`,
5050
edgeCases["nested ternary with correct getter"],
5151
);
52+
test(
53+
`${ruleName}: ✅ Edge - if/else with correct getter in both branches`,
54+
edgeCases["if else with correct getter in both branches"],
55+
);
56+
test(
57+
`${ruleName}: ❌ Edge - if/else with wrong getter in if block`,
58+
edgeCases["if else with wrong getter in if block"],
59+
);
60+
test(
61+
`${ruleName}: ❌ Edge - if/else with wrong getter in else block`,
62+
edgeCases["if else with wrong getter in else block"],
63+
);
64+
test(
65+
`${ruleName}: ❌ Edge - if/else with wrong getter in both blocks`,
66+
edgeCases["if else with wrong getter in both blocks"],
67+
);
68+
test(
69+
`${ruleName}: ✅ Edge - nested if with correct getter`,
70+
edgeCases["nested if with correct getter"],
71+
);
72+
test(
73+
`${ruleName}: ✅ Edge - if else if else with correct getter in all branches`,
74+
edgeCases["if else if else with correct getter in all branches"],
75+
);
76+
test(
77+
`${ruleName}: ❌ Edge - if else if else with wrong getter in else if`,
78+
edgeCases["if else if else with wrong getter in else if"],
79+
);
80+
test(
81+
`${ruleName}: ✅ Edge - if else if with final return correct getter in all paths`,
82+
edgeCases["if else if with final return correct getter in all paths"],
83+
);
84+
test(
85+
`${ruleName}: ❌ Edge - if else if with final return wrong getter in final return`,
86+
edgeCases["if else if with final return wrong getter in final return"],
87+
);

packages/lint/src/tests/actor-featured-tags-property-required.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,39 @@ test(
7979
`${ruleName}: ✅ Edge - nested ternary with property`,
8080
edgeCases["nested ternary with property"],
8181
);
82+
test(
83+
`${ruleName}: ✅ Edge - if/else with property in both branches`,
84+
edgeCases["if else with property in both branches"],
85+
);
86+
test(
87+
`${ruleName}: ❌ Edge - if/else missing property in if block`,
88+
edgeCases["if else missing property in if block"],
89+
);
90+
test(
91+
`${ruleName}: ❌ Edge - if/else missing property in else block`,
92+
edgeCases["if else missing property in else block"],
93+
);
94+
test(
95+
`${ruleName}: ❌ Edge - if/else missing property in both blocks`,
96+
edgeCases["if else missing property in both blocks"],
97+
);
98+
test(
99+
`${ruleName}: ✅ Edge - nested if with property`,
100+
edgeCases["nested if with property"],
101+
);
102+
test(
103+
`${ruleName}: ✅ Edge - if else if else with featuredTags in all branches`,
104+
edgeCases["if else if else with property in all branches"],
105+
);
106+
test(
107+
`${ruleName}: ❌ Edge - if else if else missing featuredTags in else if`,
108+
edgeCases["if else if else missing property in else if"],
109+
);
110+
test(
111+
`${ruleName}: ✅ Edge - if else if with final return featuredTags in all paths`,
112+
edgeCases["if else if with final return property in all paths"],
113+
);
114+
test(
115+
`${ruleName}: ❌ Edge - if else if with final return missing featuredTags in final return`,
116+
edgeCases["if else if with final return missing property in final return"],
117+
);

packages/lint/src/tests/actor-followers-property-mismatch.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,39 @@ test(
4949
`${ruleName}: ✅ Edge - nested ternary with correct getter`,
5050
edgeCases["nested ternary with correct getter"],
5151
);
52+
test(
53+
`${ruleName}: ✅ Edge - if/else with correct getter in both branches`,
54+
edgeCases["if else with correct getter in both branches"],
55+
);
56+
test(
57+
`${ruleName}: ❌ Edge - if/else with wrong getter in if block`,
58+
edgeCases["if else with wrong getter in if block"],
59+
);
60+
test(
61+
`${ruleName}: ❌ Edge - if/else with wrong getter in else block`,
62+
edgeCases["if else with wrong getter in else block"],
63+
);
64+
test(
65+
`${ruleName}: ❌ Edge - if/else with wrong getter in both blocks`,
66+
edgeCases["if else with wrong getter in both blocks"],
67+
);
68+
test(
69+
`${ruleName}: ✅ Edge - nested if with correct getter`,
70+
edgeCases["nested if with correct getter"],
71+
);
72+
test(
73+
`${ruleName}: ✅ Edge - if else if else with correct getter in all branches`,
74+
edgeCases["if else if else with correct getter in all branches"],
75+
);
76+
test(
77+
`${ruleName}: ❌ Edge - if else if else with wrong getter in else if`,
78+
edgeCases["if else if else with wrong getter in else if"],
79+
);
80+
test(
81+
`${ruleName}: ✅ Edge - if else if with final return correct getter in all paths`,
82+
edgeCases["if else if with final return correct getter in all paths"],
83+
);
84+
test(
85+
`${ruleName}: ❌ Edge - if else if with final return wrong getter in final return`,
86+
edgeCases["if else if with final return wrong getter in final return"],
87+
);

packages/lint/src/tests/actor-followers-property-required.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,39 @@ test(
7979
`${ruleName}: ✅ Edge - nested ternary with property`,
8080
edgeCases["nested ternary with property"],
8181
);
82+
test(
83+
`${ruleName}: ✅ Edge - if/else with property in both branches`,
84+
edgeCases["if else with property in both branches"],
85+
);
86+
test(
87+
`${ruleName}: ❌ Edge - if/else missing property in if block`,
88+
edgeCases["if else missing property in if block"],
89+
);
90+
test(
91+
`${ruleName}: ❌ Edge - if/else missing property in else block`,
92+
edgeCases["if else missing property in else block"],
93+
);
94+
test(
95+
`${ruleName}: ❌ Edge - if/else missing property in both blocks`,
96+
edgeCases["if else missing property in both blocks"],
97+
);
98+
test(
99+
`${ruleName}: ✅ Edge - nested if with property`,
100+
edgeCases["nested if with property"],
101+
);
102+
test(
103+
`${ruleName}: ✅ Edge - if else if else with followers in all branches`,
104+
edgeCases["if else if else with property in all branches"],
105+
);
106+
test(
107+
`${ruleName}: ❌ Edge - if else if else missing followers in else if`,
108+
edgeCases["if else if else missing property in else if"],
109+
);
110+
test(
111+
`${ruleName}: ✅ Edge - if else if with final return followers in all paths`,
112+
edgeCases["if else if with final return property in all paths"],
113+
);
114+
test(
115+
`${ruleName}: ❌ Edge - if else if with final return missing followers in final return`,
116+
edgeCases["if else if with final return missing property in final return"],
117+
);

packages/lint/src/tests/actor-following-property-mismatch.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,39 @@ test(
4949
`${ruleName}: ✅ Edge - nested ternary with correct getter`,
5050
edgeCases["nested ternary with correct getter"],
5151
);
52+
test(
53+
`${ruleName}: ✅ Edge - if/else with correct getter in both branches`,
54+
edgeCases["if else with correct getter in both branches"],
55+
);
56+
test(
57+
`${ruleName}: ❌ Edge - if/else with wrong getter in if block`,
58+
edgeCases["if else with wrong getter in if block"],
59+
);
60+
test(
61+
`${ruleName}: ❌ Edge - if/else with wrong getter in else block`,
62+
edgeCases["if else with wrong getter in else block"],
63+
);
64+
test(
65+
`${ruleName}: ❌ Edge - if/else with wrong getter in both blocks`,
66+
edgeCases["if else with wrong getter in both blocks"],
67+
);
68+
test(
69+
`${ruleName}: ✅ Edge - nested if with correct getter`,
70+
edgeCases["nested if with correct getter"],
71+
);
72+
test(
73+
`${ruleName}: ✅ Edge - if else if else with correct getter in all branches`,
74+
edgeCases["if else if else with correct getter in all branches"],
75+
);
76+
test(
77+
`${ruleName}: ❌ Edge - if else if else with wrong getter in else if`,
78+
edgeCases["if else if else with wrong getter in else if"],
79+
);
80+
test(
81+
`${ruleName}: ✅ Edge - if else if with final return correct getter in all paths`,
82+
edgeCases["if else if with final return correct getter in all paths"],
83+
);
84+
test(
85+
`${ruleName}: ❌ Edge - if else if with final return wrong getter in final return`,
86+
edgeCases["if else if with final return wrong getter in final return"],
87+
);

packages/lint/src/tests/actor-following-property-required.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,39 @@ test(
7979
`${ruleName}: ✅ Edge - nested ternary with property`,
8080
edgeCases["nested ternary with property"],
8181
);
82+
test(
83+
`${ruleName}: ✅ Edge - if/else with property in both branches`,
84+
edgeCases["if else with property in both branches"],
85+
);
86+
test(
87+
`${ruleName}: ❌ Edge - if/else missing property in if block`,
88+
edgeCases["if else missing property in if block"],
89+
);
90+
test(
91+
`${ruleName}: ❌ Edge - if/else missing property in else block`,
92+
edgeCases["if else missing property in else block"],
93+
);
94+
test(
95+
`${ruleName}: ❌ Edge - if/else missing property in both blocks`,
96+
edgeCases["if else missing property in both blocks"],
97+
);
98+
test(
99+
`${ruleName}: ✅ Edge - nested if with property`,
100+
edgeCases["nested if with property"],
101+
);
102+
test(
103+
`${ruleName}: ✅ Edge - if else if else with following in all branches`,
104+
edgeCases["if else if else with property in all branches"],
105+
);
106+
test(
107+
`${ruleName}: ❌ Edge - if else if else missing following in else if`,
108+
edgeCases["if else if else missing property in else if"],
109+
);
110+
test(
111+
`${ruleName}: ✅ Edge - if else if with final return following in all paths`,
112+
edgeCases["if else if with final return property in all paths"],
113+
);
114+
test(
115+
`${ruleName}: ❌ Edge - if else if with final return missing following in final return`,
116+
edgeCases["if else if with final return missing property in final return"],
117+
);

0 commit comments

Comments
 (0)