Skip to content

Commit 6545caa

Browse files
committed
tests: Add examples to QueryProperties.test.query_file_properties.approved.md
For later embedding in the user docs.
1 parent 972e8f6 commit 6545caa

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tests/Scripting/QueryProperties.test.query_file_properties.approved.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
| `query.file.folder` | `string` | `'root/sub-folder/'` |
99
| `query.file.filename` | `string` | `'file containing query.md'` |
1010
| `query.file.filenameWithoutExtension` | `string` | `'file containing query'` |
11+
| `query.file.hasProperty('task_instruction')` | `boolean` | `true` |
12+
| `query.file.hasProperty('non_existent_property')` | `boolean` | `false` |
13+
| `query.file.property('task_instruction')` | `string` | `'group by filename'` |
14+
| `query.file.property('non_existent_property')` | `null` | `null` |
1115

1216

1317
<!-- placeholder to force blank line after included text -->

tests/Scripting/QueryProperties.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import { MarkdownTable } from '../../src/lib/MarkdownTable';
55
import { parseAndEvaluateExpression } from '../../src/Scripting/TaskExpression';
66
import { TaskBuilder } from '../TestingTools/TaskBuilder';
77
import { TasksFile } from '../../src/Scripting/TasksFile';
8+
import { getTasksFileFromMockData } from '../TestingTools/MockDataHelpers';
9+
import query_using_properties from '../Obsidian/__test_data__/query_using_properties.json';
810
import { addBackticks, determineExpressionType, formatToRepresentType } from './ScriptingTestHelpers';
911

1012
describe('query', () => {
1113
function verifyFieldDataForReferenceDocs(fields: string[]) {
1214
const markdownTable = new MarkdownTable(['Field', 'Type', 'Example']);
13-
const tasksFile = new TasksFile('root/sub-folder/file containing query.md');
15+
const cachedMetadata = getTasksFileFromMockData(query_using_properties).cachedMetadata;
16+
const tasksFile = new TasksFile('root/sub-folder/file containing query.md', cachedMetadata);
1417
const task = new TaskBuilder()
1518
.description('... an array with all the Tasks-tracked tasks in the vault ...')
1619
.build();
@@ -35,6 +38,10 @@ describe('query', () => {
3538
'query.file.folder',
3639
'query.file.filename',
3740
'query.file.filenameWithoutExtension',
41+
"query.file.hasProperty('task_instruction')",
42+
"query.file.hasProperty('non_existent_property')",
43+
"query.file.property('task_instruction')",
44+
"query.file.property('non_existent_property')",
3845
]);
3946
});
4047

0 commit comments

Comments
 (0)