Skip to content

Commit 50fc40b

Browse files
committed
test: Include the grouper names in TaskGroups snapshot tests
1 parent c347144 commit 50fc40b

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

src/Query/TaskGroups.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class TaskGroups {
7171
*/
7272
public toString(): string {
7373
let output = '';
74+
output += 'Groupers (if any):\n';
75+
for (const grouper of this._groupers) {
76+
const reverseText = grouper.reverse ? ' reverse' : '';
77+
output += `- ${grouper.property}${reverseText}\n`;
78+
}
7479
for (const taskGroup of this.groups) {
7580
output += taskGroup.toString();
7681
output += '\n---\n';

tests/Query/Filter/TagsField.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,9 @@ describe('grouping by tag', () => {
659659

660660
// Assert
661661
expect(groups.toString()).toMatchInlineSnapshot(`
662-
"
662+
"Groupers (if any):
663+
- tags reverse
664+
663665
Group names: [#tag2]
664666
#### #tag2
665667
- [ ] b #tag2

tests/TaskGroups.test.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ describe('Grouping tasks', () => {
3131
// Assert
3232
expect(groups.groupers).toStrictEqual(grouping);
3333
expect(groups.toString()).toMatchInlineSnapshot(`
34-
"
34+
"Groupers (if any):
35+
- path
36+
3537
Group names: [file1]
3638
#### file1
3739
- [ ] b
@@ -64,7 +66,8 @@ describe('Grouping tasks', () => {
6466
// Assert
6567
// No grouping specified, so no headings generated
6668
expect(groups.toString()).toMatchInlineSnapshot(`
67-
"
69+
"Groupers (if any):
70+
6871
Group names: []
6972
- [ ] a 📅 1970-01-01
7073
- [ ] b 📅 1970-01-02
@@ -109,7 +112,9 @@ describe('Grouping tasks', () => {
109112
const grouping = [new PathField().createNormalGrouper()];
110113
const groups = new TaskGroups(grouping, inputs);
111114
expect(groups.toString()).toMatchInlineSnapshot(`
112-
"
115+
"Groupers (if any):
116+
- path
117+
113118
Group names: [a/b/c]
114119
#### a/b/c
115120
- [ ] first file path, alphabetically
@@ -147,7 +152,9 @@ describe('Grouping tasks', () => {
147152
const grouping = [new FilenameField().createNormalGrouper()];
148153
const groups = new TaskGroups(grouping, inputs);
149154
expect(groups.toString()).toMatchInlineSnapshot(`
150-
"
155+
"Groupers (if any):
156+
- filename
157+
151158
Group names: [[[9 something]]]
152159
#### [[9 something]]
153160
- [ ] first, as 9 is less then 10
@@ -178,7 +185,9 @@ describe('Grouping tasks', () => {
178185
// Assert
179186
// No grouping specified, so no headings generated
180187
expect(groups.toString()).toMatchInlineSnapshot(`
181-
"
188+
"Groupers (if any):
189+
- due reverse
190+
182191
Group names: [2023-07-08 Saturday]
183192
#### 2023-07-08 Saturday
184193
- [ ] b 📅 2023-07-08
@@ -211,7 +220,9 @@ describe('Grouping tasks', () => {
211220
const grouping = [new TagsField().createNormalGrouper()];
212221
const groups = new TaskGroups(grouping, inputs);
213222
expect(groups.toString()).toMatchInlineSnapshot(`
214-
"
223+
"Groupers (if any):
224+
- tags
225+
215226
Group names: [#group1]
216227
#### #group1
217228
- [ ] Task 1 #group1
@@ -257,7 +268,10 @@ describe('Grouping tasks', () => {
257268

258269
// Assert
259270
expect(groups.toString()).toMatchInlineSnapshot(`
260-
"
271+
"Groupers (if any):
272+
- folder reverse
273+
- filename
274+
261275
Group names: [folder\\_b/folder\\_c/,[[file_c]]]
262276
#### folder\\_b/folder\\_c/
263277
##### [[file_c]]
@@ -303,7 +317,10 @@ describe('Grouping tasks', () => {
303317
// This result is incorrect. The '2 TODO' heading is shown before
304318
// the last group instead of before the first one.
305319
expect(groups.toString()).toMatchInlineSnapshot(`
306-
"
320+
"Groupers (if any):
321+
- status.type
322+
- happens
323+
307324
Group names: [2 TODO,2022-09-19 Monday]
308325
#### 2 TODO
309326
##### 2022-09-19 Monday

0 commit comments

Comments
 (0)