Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: 💍 add test for sub-expression variables #71644

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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