Files
directus/packages/utils/shared/to-boolean.test.ts
Hannes Küttner 97bf47e67c Change guessType to retain value types if they are known (#22349)
* Improve env variable casting for already typed variables configured through .[c]js files

* Revert back to using dedicated toX functions and extended toBoolean to handle boolean type values

* Some additions to test and removed some redundant code in toBoolean

* Fix test case name

* Add changeset

* Change changeset
2024-05-02 17:42:35 +08:00

19 lines
370 B
TypeScript

import { expect, test } from 'vitest';
import { toBoolean } from './to-boolean.js';
test.each([
['true', true],
[true, true],
['1', true],
[1, true],
['false', false],
['anything', false],
[123, false],
[{}, false],
[['{}'], false],
[true, true],
[false, false],
])('toBoolean(%s) -> %s', (value, expected) => {
expect(toBoolean(value)).toBe(expected);
});