2024-03-20 04:05:54 -07:00
|
|
|
/**
|
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { evaluate } from './Helpers';
|
2024-09-18 00:19:33 -07:00
|
|
|
import { booleanExtensions } from '../../src/Extensions/BooleanExtensions';
|
2024-03-20 04:05:54 -07:00
|
|
|
|
|
|
|
describe('Data Transformation Functions', () => {
|
|
|
|
describe('Boolean Data Transformation Functions', () => {
|
|
|
|
describe('Conversion methods', () => {
|
|
|
|
describe('toInt/toFloat', () => {
|
|
|
|
test('should return 1 for true, 0 for false', () => {
|
|
|
|
expect(evaluate('={{ (true).toInt() }}')).toEqual(1);
|
|
|
|
expect(evaluate('={{ (true).toFloat() }}')).toEqual(1);
|
|
|
|
expect(evaluate('={{ (false).toInt() }}')).toEqual(0);
|
|
|
|
expect(evaluate('={{ (false).toFloat() }}')).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('toDateTime', () => {
|
|
|
|
test('should return undefined', () => {
|
|
|
|
expect(evaluate('={{ (true).toDateTime() }}')).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('toBoolean', () => {
|
|
|
|
test('should return itself', () => {
|
|
|
|
expect(evaluate('={{ (true).toDateTime() }}')).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should not have a doc (hidden from autocomplete)', () => {
|
|
|
|
expect(booleanExtensions.functions.toFloat.doc).toBeUndefined();
|
|
|
|
expect(booleanExtensions.functions.toBoolean.doc).toBeUndefined();
|
|
|
|
expect(booleanExtensions.functions.toDateTime.doc).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|