Skip to content

Commit 8083ea4

Browse files
committed
test: - Make visible the explanations for multi-level {{includes...}}
1 parent c3cfa36 commit 8083ea4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/Scripting/Includes.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,42 @@ describe('include tests', () => {
173173
'root includes root/',
174174
];
175175

176+
it('includes placeholder should support placeholders inside simple instructions', () => {
177+
const source = '{{includes.this_path}}\n{{includes.this_folder}}\n{{includes.this_root}}';
178+
const query = createValidQuery(source, includes);
179+
expect(query.filters.map((filter) => filter.statement.anyPlaceholdersExpanded)).toEqual(
180+
expectedFilterLines,
181+
);
182+
expect(query.explainQuery()).toMatchInlineSnapshot(`
183+
"{{includes.this_path}} =>
184+
path includes root/folder/stuff.md
185+
186+
{{includes.this_folder}} =>
187+
folder includes root/folder/
188+
189+
{{includes.this_root}} =>
190+
root includes root/
191+
"
192+
`);
193+
});
194+
176195
it('includes placeholder should support one-level nested placeholders', () => {
177196
const source = '{{includes.this_everything}}';
178197
const query = createValidQuery(source, includes);
179198
expect(query.filters.map((filter) => filter.statement.anyPlaceholdersExpanded)).toEqual(
180199
expectedFilterLines,
181200
);
201+
expect(query.explainQuery()).toMatchInlineSnapshot(`
202+
"{{includes.this_everything}}: statement 1 after expansion of placeholder =>
203+
path includes root/folder/stuff.md
204+
205+
{{includes.this_everything}}: statement 2 after expansion of placeholder =>
206+
folder includes root/folder/
207+
208+
{{includes.this_everything}}: statement 3 after expansion of placeholder =>
209+
root includes root/
210+
"
211+
`);
182212
});
183213

184214
it('includes placeholder should support two-level nested placeholders', () => {
@@ -187,6 +217,17 @@ describe('include tests', () => {
187217
expect(query.filters.map((filter) => filter.statement.anyPlaceholdersExpanded)).toEqual(
188218
expectedFilterLines,
189219
);
220+
expect(query.explainQuery()).toMatchInlineSnapshot(`
221+
"{{includes.this_everything_indirect}}: statement 1 after expansion of placeholder =>
222+
path includes root/folder/stuff.md
223+
224+
{{includes.this_everything_indirect}}: statement 2 after expansion of placeholder =>
225+
folder includes root/folder/
226+
227+
{{includes.this_everything_indirect}}: statement 3 after expansion of placeholder =>
228+
root includes root/
229+
"
230+
`);
190231
});
191232
});
192233

0 commit comments

Comments
 (0)