Skip to content

Commit 4b9618d

Browse files
committed
test: Guard against accidental creation of test tasks that would be ignored
1 parent d7de606 commit 4b9618d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Renderer/QueryResultsRenderer.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ describe('QueryResultsRenderer - internal heading links', () => {
127127

128128
tasksByHeading = allTasks.reduce((acc, task) => {
129129
const heading = task.taskLocation.precedingHeader ?? '';
130+
131+
// For now, the test design only supports one task per heading, so make it an error
132+
// if there are multiple tasks in this heading:
133+
if (acc[heading]) {
134+
throw new Error(`Multiple tasks found under the heading: "${heading}".
135+
The test design only supports one task per heading currently, so this is an error.
136+
137+
Edit "${task.path}" to move one of these lines to a separate heading:
138+
"${acc[heading].originalMarkdown}"
139+
"${task.originalMarkdown}"
140+
141+
And then rerun the command "Templater: Insert _meta/templates/convert_test_data_markdown_to_js.md".
142+
143+
For more info: https://publish.obsidian.md/tasks-contributing/Testing/Using+Obsidian+API+in+tests
144+
`);
145+
}
146+
130147
acc[heading] = task;
131148
return acc;
132149
}, {} as Record<string, Task>);

0 commit comments

Comments
 (0)