@@ -7,39 +7,42 @@ import { makeQueryContext } from '../../src/Scripting/QueryContext';
7
7
import { FunctionField } from '../../src/Query/Filter/FunctionField' ;
8
8
import { SearchInfo } from '../../src/Query/SearchInfo' ;
9
9
10
+ const path = 'a/b/c.md' ;
11
+ const task = new TaskBuilder ( ) . path ( path ) . build ( ) ;
12
+ const queryContext = makeQueryContext ( path ) ;
13
+
10
14
describe ( 'QueryContext' , ( ) => {
11
15
describe ( 'values should all match their corresponding filters' , ( ) => {
12
- const path = 'a/b/c.md' ;
13
- const task = new TaskBuilder ( ) . path ( path ) . build ( ) ;
14
- const queryContext = makeQueryContext ( path ) ;
15
-
16
- it ( 'root' , ( ) => {
16
+ it ( 'query.file.root' , ( ) => {
17
17
const instruction = `root includes ${ queryContext . query . file . root } ` ;
18
18
const filter = new RootField ( ) . createFilterOrErrorMessage ( instruction ) ;
19
19
expect ( filter ) . toMatchTask ( task ) ;
20
20
} ) ;
21
21
22
- it ( 'path' , ( ) => {
22
+ it ( 'query.file. path' , ( ) => {
23
23
const instruction = `path includes ${ queryContext . query . file . path } ` ;
24
24
const filter = new PathField ( ) . createFilterOrErrorMessage ( instruction ) ;
25
25
expect ( filter ) . toMatchTask ( task ) ;
26
26
} ) ;
27
27
28
- it ( 'folder' , ( ) => {
28
+ it ( 'query.file. folder' , ( ) => {
29
29
const instruction = `folder includes ${ queryContext . query . file . folder } ` ;
30
30
const filter = new FolderField ( ) . createFilterOrErrorMessage ( instruction ) ;
31
31
expect ( filter ) . toMatchTask ( task ) ;
32
32
} ) ;
33
33
34
- it ( 'filename' , ( ) => {
34
+ it ( 'query.file. filename' , ( ) => {
35
35
const instruction = `filename includes ${ queryContext . query . file . filename } ` ;
36
36
const filter = new FilenameField ( ) . createFilterOrErrorMessage ( instruction ) ;
37
37
expect ( filter ) . toMatchTask ( task ) ;
38
38
} ) ;
39
+ } ) ;
39
40
40
- it ( 'allTasks' , ( ) => {
41
+ describe ( 'non-file properties' , ( ) => {
42
+ it ( 'query.allTasks' , ( ) => {
41
43
// Arrange
42
- // An artificial example, just to demonstrate that query.allTasks is accessible via scripting
44
+ // An artificial example, just to demonstrate that query.allTasks is accessible via scripting,
45
+ // when the SearchInfo parameter is converted to a QueryContext.
43
46
const instruction = 'group by function query.allTasks.length' ;
44
47
const grouper = new FunctionField ( ) . createGrouperFromLine ( instruction ) ;
45
48
expect ( grouper ) . not . toBeNull ( ) ;
0 commit comments