Test with complex expression with arithmetic, relational, and logical operators

This commit is contained in:
Matt Sherman 2023-10-04 10:02:15 -04:00
parent 83c3ff365a
commit 1812a76f8d
1 changed files with 17 additions and 0 deletions

View File

@ -326,6 +326,23 @@ describe( 'evaluate', () => {
expect( result ).toEqual( true );
} );
it( 'should evaluate a complex expression with arithmetic, relational, and logical operators', () => {
const result = evaluate(
`foo.bar
&& ( foo.baz === "qux" || foo.baz === "quux" )
&& ( foo.quux > 1 && foo.quux <= 5 )`,
{
foo: {
bar: true,
baz: 'quux',
quux: 10,
},
}
);
expect( result ).toEqual( false );
} );
it( 'should evaluate an expression with needless parentheses', () => {
const result = evaluate( '(((foo)))', {
foo: true,