Skip to content

Commit

Permalink
test: Convert custom filter samples from placeholders to query proper…
Browse files Browse the repository at this point in the history
…ties
  • Loading branch information
claremacrae committed Oct 29, 2023
1 parent 1d9240a commit 4b11955
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ filter by function task.file.folder.includes("Work/Projects/")
- Find tasks in files in a specific folder **and any sub-folders**.

```javascript
filter by function task.file.folder.includes( '{{query.file.folder}}' )
filter by function task.file.folder.includes( query.file.folder )
```

- Find tasks in files in the folder that contains the query **and any sub-folders**.
- Note that the placeholder text is expanded to a raw string, so needs to be inside quotes.

```javascript
filter by function task.file.folder === '{{query.file.folder}}'
filter by function task.file.folder === query.file.folder
```

- Find tasks in files in the folder that contains the query only (**not tasks in any sub-folders**).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ Find tasks in files in a specific folder **and any sub-folders**.
====================================================================================


filter by function task.file.folder.includes( '{{query.file.folder}}' )
filter by function task.file.folder.includes( query.file.folder )
Find tasks in files in the folder that contains the query **and any sub-folders**.
Note that the placeholder text is expanded to a raw string, so needs to be inside quotes.
=>
- [ ] xyz in a/b.md
- [ ] xyz in a/b/c.md
Expand All @@ -31,7 +30,7 @@ Note that the placeholder text is expanded to a raw string, so needs to be insid
====================================================================================


filter by function task.file.folder === '{{query.file.folder}}'
filter by function task.file.folder === query.file.folder
Find tasks in files in the folder that contains the query only (**not tasks in any sub-folders**).
=>
- [ ] xyz in a/b.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,11 @@ describe('file properties', () => {
'Find tasks in files in a specific folder **and any sub-folders**',
],
[
"filter by function task.file.folder.includes( '{{query.file.folder}}' )",
'filter by function task.file.folder.includes( query.file.folder )',
'Find tasks in files in the folder that contains the query **and any sub-folders**',
'Note that the placeholder text is expanded to a raw string, so needs to be inside quotes.',
],
[
"filter by function task.file.folder === '{{query.file.folder}}'",
'filter by function task.file.folder === query.file.folder',
'Find tasks in files in the folder that contains the query only (**not tasks in any sub-folders**)',
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ export function verifyFunctionFieldFilterSamplesOnTasks(filters: QueryInstructio
const instruction = filter[0];
const comment = filter.slice(1);

const expandedInstruction = preprocessSingleInstruction(instruction, 'a/b.md');
const path = 'a/b.md';
const expandedInstruction = preprocessSingleInstruction(instruction, path);
const filterOrErrorMessage = new FunctionField().createFilterOrErrorMessage(expandedInstruction);
expect(filterOrErrorMessage).toBeValid();

const filterFunction = filterOrErrorMessage.filterFunction!;
const matchingTasks: string[] = [];
const searchInfo = SearchInfo.fromAllTasks(tasks);
const searchInfo = new SearchInfo(path, tasks);
for (const task of tasks) {
const matches = filterFunction(task, searchInfo);
if (matches) {
Expand Down

0 comments on commit 4b11955

Please sign in to comment.