Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { evaluate } from './helpers';
|
|
import { booleanExtensions } from '../../src/extensions/boolean-extensions';
|
|
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
});
|