test(core): Add basic expression tests (no-changelog) (#5439)

* test(core): add basic expression tests

* test: fix $if test not working properly
This commit is contained in:
Valya
2023-02-10 09:05:34 +00:00
committed by GitHub
parent 5b1e3a3fd3
commit 287fa9cd06
4 changed files with 725 additions and 8 deletions

View File

@@ -209,13 +209,11 @@ describe('tmpl Expression Parser', () => {
// If you're implementing sandboxing maybe provide a way to add functions to
// sandbox we can check instead?
const mockCallback = jest.fn(() => false);
// @ts-ignore
evaluate('={{ $if("a"==="a", true, $data["cb"]()) }}', [{ cb: mockCallback }]);
evaluate('={{ $if("a"==="a", true, $data.cb()) }}', [{ cb: mockCallback }]);
expect(mockCallback.mock.calls.length).toEqual(0);
// @ts-ignore
evaluate('={{ $if("a"==="b", true, $data["cb"]()) }}', [{ cb: mockCallback }]);
expect(mockCallback.mock.calls.length).toEqual(0);
evaluate('={{ $if("a"==="b", true, $data.cb()) }}', [{ cb: mockCallback }]);
expect(mockCallback.mock.calls.length).toEqual(1);
});
test('$not', () => {