feel
feel copied to clipboard
not(true) seems not to work
In the following test suite, the tests 'evaluates true = true'
and 'evaluates true = false'
are evaluated correctly, showing the js-feel implementation seems to work properly, however the tests 'not(true)'
and 'not(false)'
evaluate to a Function (not to a boolean
). If I try to call the function it throws an error "TypeError: Cannot read properties of undefined (reading 'isDate')"
.
Any help is appreciated.
const feel = require('js-feel/dist/feel');
describe( 'inbuild "not" function', () => {
it( 'evaluates not(true)', async () => {
const notTrue = 'not(true)'
const ast = await feel.parse( notTrue );
const result = await ast.build({});
expect( result ).toBe( false ); // -> Function
});
it( 'evaluates not(false)', async () => {
const notFalse = 'not(false)'
const ast = await feel.parse( notFalse );
const result = await ast.build({});
expect( result ).toBe( true ); // -> Function
});
it( 'evaluates not(true) - with function', async () => {
const notTrue = 'not(true)'
const ast = await feel.parse( notTrue);
let result = await ast.build({});
if( typeof result === 'function' ) result = result();
expect( result ).toBe( false ); // -> "TypeError: Cannot read properties of undefined (reading 'isDate')"
});
it( 'evaluates true = true', async () => {
const notTrue = 'true = true'
const ast = await feel.parse( notTrue);
const result = await ast.build({});
expect( result ).toBe( true ); // -> ok
});
it( 'evaluates true = false', async () => {
const notTrue = 'true = false'
const ast = await feel.parse( notTrue);
const result = await ast.build({});
expect( result ).toBe( false ); // -> ok
});
});
Anyone? I can't believe I'm the only one having an issue with such a basic feature. Am I missing something?