Skip to content

Commit a44c8a1

Browse files
committed
test: 💍 add test for sub-expression variables
1 parent 1ceaea1 commit a44c8a1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/plugins/expressions/common/execution/execution.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,38 @@ describe('Execution', () => {
376376
value: 5,
377377
});
378378
});
379+
380+
test('can use global variables', async () => {
381+
const result = await run(
382+
'add val={var foo}',
383+
{
384+
variables: {
385+
foo: 3,
386+
},
387+
},
388+
null
389+
);
390+
391+
expect(result).toMatchObject({
392+
type: 'num',
393+
value: 3,
394+
});
395+
});
396+
397+
test('can modify global variables', async () => {
398+
const result = await run(
399+
'add val={var_set name=foo value=66 | var bar} | var foo',
400+
{
401+
variables: {
402+
foo: 3,
403+
bar: 25,
404+
},
405+
},
406+
null
407+
);
408+
409+
expect(result).toBe(66);
410+
});
379411
});
380412

381413
describe('when arguments are missing', () => {

0 commit comments

Comments
 (0)