feat(editor): Add missing extension methods for expressions (#8845)

This commit is contained in:
Elias Meire
2024-03-20 12:05:54 +01:00
committed by GitHub
parent 7176cd1407
commit 5e84c2ab89
28 changed files with 809 additions and 39 deletions

View File

@@ -1,3 +1,4 @@
import { objectExtensions } from '../../src/Extensions/ObjectExtensions';
import { evaluate } from './Helpers';
describe('Data Transformation Functions', () => {
@@ -89,5 +90,27 @@ describe('Data Transformation Functions', () => {
test('.values should work on an object', () => {
expect(evaluate('={{ ({ test1: 1, test2: "2" }).values() }}')).toEqual([1, '2']);
});
test('.toJsonString() should work on an object', () => {
expect(evaluate('={{ ({ test1: 1, test2: "2" }).toJsonString() }}')).toEqual(
'{"test1":1,"test2":"2"}',
);
});
describe('Conversion methods', () => {
test('should exist but return undefined (to not break expressions with mixed data)', () => {
expect(evaluate('={{ ({ test1: 1, test2: "2" }).toInt() }}')).toBeUndefined();
expect(evaluate('={{ ({ test1: 1, test2: "2" }).toFloat() }}')).toBeUndefined();
expect(evaluate('={{ ({ test1: 1, test2: "2" }).toBoolean() }}')).toBeUndefined();
expect(evaluate('={{ ({ test1: 1, test2: "2" }).toDateTime() }}')).toBeUndefined();
});
it('should not have a doc (hidden from autocomplete)', () => {
expect(objectExtensions.functions.toInt.doc).toBeUndefined();
expect(objectExtensions.functions.toFloat.doc).toBeUndefined();
expect(objectExtensions.functions.toBoolean.doc).toBeUndefined();
expect(objectExtensions.functions.toDateTime.doc).toBeUndefined();
});
});
});
});