Skip to content

Commit

Permalink
[canvas] Run tests against @kbn/handlebars compileAST function (#150439)
Browse files Browse the repository at this point in the history
The `Handlebars` object exposed by the tested file
(`x-pack/plugins/canvas/common/lib/handlebars.js`) is primarily meant to
have its `compileAST` function called and not the `compile` function.
This PR just updates the tests to reflect that.
  • Loading branch information
Thomas Watson authored Feb 8, 2023
1 parent 01f07bc commit f4c7330
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/canvas/common/lib/handlebars.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { Handlebars } from './handlebars';

describe('handlebars', () => {
it('registers math function and returns argument error', () => {
const template = Handlebars.compile("test math: {{math rows 'mean(price * quantity)' 2}}");
const template = Handlebars.compileAST("test math: {{math rows 'mean(price * quantity)' 2}}");
expect(template()).toBe('test math: MATH ERROR: first argument must be an array');
});
it('evaluates math function successfully', () => {
const template = Handlebars.compile("test math: {{math rows 'mean(price * quantity)' 2}}");
const template = Handlebars.compileAST("test math: {{math rows 'mean(price * quantity)' 2}}");
expect(template(testTable)).toBe('test math: 82164.33');
});
});

0 comments on commit f4c7330

Please sign in to comment.