Skip to content

Commit

Permalink
test: 💍 add test for sub-expression variables
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 14, 2020
1 parent 1ceaea1 commit a44c8a1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/plugins/expressions/common/execution/execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,38 @@ describe('Execution', () => {
value: 5,
});
});

test('can use global variables', async () => {
const result = await run(
'add val={var foo}',
{
variables: {
foo: 3,
},
},
null
);

expect(result).toMatchObject({
type: 'num',
value: 3,
});
});

test('can modify global variables', async () => {
const result = await run(
'add val={var_set name=foo value=66 | var bar} | var foo',
{
variables: {
foo: 3,
bar: 25,
},
},
null
);

expect(result).toBe(66);
});
});

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

0 comments on commit a44c8a1

Please sign in to comment.