Skip to content

Commit

Permalink
test: 💍 add test for sub-expression variables (#71644)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
streamich and elasticmachine committed Jul 23, 2020
1 parent 5cdd080 commit 4b359f4
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 4b359f4

Please sign in to comment.