Skip to content

Commit

Permalink
test: 💍 add test for sub-expression variables (#71644) (#73005)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
streamich and elasticmachine authored Jul 23, 2020
1 parent 4bc7c59 commit a2101c9
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 a2101c9

Please sign in to comment.