Skip to content

Commit dd630bf

Browse files
Split tests up into describe blocks
1 parent a8a84a6 commit dd630bf

File tree

1 file changed

+77
-73
lines changed

1 file changed

+77
-73
lines changed

extensions/ql-vscode/test/unit-tests/variant-analysis-filter-sort.test.ts

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,88 +14,92 @@ describe(matchesFilter.name, () => {
1414
fullName: "github/codeql",
1515
};
1616

17-
const testCases = [
18-
{ searchValue: "", matches: true },
19-
{ searchValue: "github/codeql", matches: true },
20-
{ searchValue: "github", matches: true },
21-
{ searchValue: "git", matches: true },
22-
{ searchValue: "codeql", matches: true },
23-
{ searchValue: "code", matches: true },
24-
{ searchValue: "ql", matches: true },
25-
{ searchValue: "/", matches: true },
26-
{ searchValue: "gothub/codeql", matches: false },
27-
{ searchValue: "hello", matches: false },
28-
{ searchValue: "cod*ql", matches: false },
29-
{ searchValue: "cod?ql", matches: false },
30-
];
17+
describe("searchValue", () => {
18+
const testCases = [
19+
{ searchValue: "", matches: true },
20+
{ searchValue: "github/codeql", matches: true },
21+
{ searchValue: "github", matches: true },
22+
{ searchValue: "git", matches: true },
23+
{ searchValue: "codeql", matches: true },
24+
{ searchValue: "code", matches: true },
25+
{ searchValue: "ql", matches: true },
26+
{ searchValue: "/", matches: true },
27+
{ searchValue: "gothub/codeql", matches: false },
28+
{ searchValue: "hello", matches: false },
29+
{ searchValue: "cod*ql", matches: false },
30+
{ searchValue: "cod?ql", matches: false },
31+
];
32+
33+
test.each(testCases)(
34+
"returns $matches if searching for $searchValue",
35+
({ searchValue, matches }) => {
36+
expect(
37+
matchesFilter(
38+
{ repository },
39+
{
40+
...defaultFilterSortState,
41+
searchValue,
42+
},
43+
),
44+
).toBe(matches);
45+
},
46+
);
47+
});
3148

32-
test.each(testCases)(
33-
"returns $matches if searching for $searchValue",
34-
({ searchValue, matches }) => {
49+
describe("filterKey", () => {
50+
it("returns true if filterKey is all and resultCount is positive", () => {
3551
expect(
3652
matchesFilter(
37-
{ repository },
38-
{
39-
...defaultFilterSortState,
40-
searchValue,
41-
},
53+
{ repository, resultCount: 1 },
54+
{ ...defaultFilterSortState, filterKey: FilterKey.All },
4255
),
43-
).toBe(matches);
44-
},
45-
);
46-
47-
it("returns true if filterKey is all and resultCount is positive", () => {
48-
expect(
49-
matchesFilter(
50-
{ repository, resultCount: 1 },
51-
{ ...defaultFilterSortState, filterKey: FilterKey.All },
52-
),
53-
).toBe(true);
54-
});
56+
).toBe(true);
57+
});
5558

56-
it("returns true if filterKey is all and resultCount is zero", () => {
57-
expect(
58-
matchesFilter(
59-
{ repository, resultCount: 0 },
60-
{ ...defaultFilterSortState, filterKey: FilterKey.All },
61-
),
62-
).toBe(true);
63-
});
59+
it("returns true if filterKey is all and resultCount is zero", () => {
60+
expect(
61+
matchesFilter(
62+
{ repository, resultCount: 0 },
63+
{ ...defaultFilterSortState, filterKey: FilterKey.All },
64+
),
65+
).toBe(true);
66+
});
6467

65-
it("returns true if filterKey is all and resultCount is undefined", () => {
66-
expect(
67-
matchesFilter(
68-
{ repository },
69-
{ ...defaultFilterSortState, filterKey: FilterKey.All },
70-
),
71-
).toBe(true);
72-
});
68+
it("returns true if filterKey is all and resultCount is undefined", () => {
69+
expect(
70+
matchesFilter(
71+
{ repository },
72+
{ ...defaultFilterSortState, filterKey: FilterKey.All },
73+
),
74+
).toBe(true);
75+
});
7376

74-
it("returns true if filterKey is withResults and resultCount is positive", () => {
75-
expect(
76-
matchesFilter(
77-
{ repository, resultCount: 1 },
78-
{ ...defaultFilterSortState, filterKey: FilterKey.WithResults },
79-
),
80-
).toBe(true);
81-
});
77+
it("returns true if filterKey is withResults and resultCount is positive", () => {
78+
expect(
79+
matchesFilter(
80+
{ repository, resultCount: 1 },
81+
{ ...defaultFilterSortState, filterKey: FilterKey.WithResults },
82+
),
83+
).toBe(true);
84+
});
8285

83-
it("returns false if filterKey is withResults and resultCount is zero", () => {
84-
expect(
85-
matchesFilter(
86-
{ repository, resultCount: 0 },
87-
{ ...defaultFilterSortState, filterKey: FilterKey.WithResults },
88-
),
89-
).toBe(false);
90-
});
86+
it("returns false if filterKey is withResults and resultCount is zero", () => {
87+
expect(
88+
matchesFilter(
89+
{ repository, resultCount: 0 },
90+
{ ...defaultFilterSortState, filterKey: FilterKey.WithResults },
91+
),
92+
).toBe(false);
93+
});
9194

92-
it("returns false if filterKey is withResults and resultCount is undefined", () => {
93-
expect(
94-
matchesFilter(
95-
{ repository },
96-
{ ...defaultFilterSortState, filterKey: FilterKey.WithResults },
97-
),
98-
).toBe(false);
95+
it("returns false if filterKey is withResults and resultCount is undefined", () => {
96+
expect(
97+
matchesFilter(
98+
{ repository },
99+
{ ...defaultFilterSortState, filterKey: FilterKey.WithResults },
100+
),
101+
).toBe(false);
102+
});
99103
});
100104
});
101105

0 commit comments

Comments
 (0)