env-utils.test.js 532 B

123456789101112131415161718192021
  1. import { toBoolean } from '~/utils/env-utils';
  2. describe('env-utils', () => {
  3. describe('.toBoolean', () => {
  4. test('should convert to true', () => {
  5. expect(toBoolean('true')).toBe(true);
  6. expect(toBoolean('True')).toBe(true);
  7. expect(toBoolean(1)).toBe(true);
  8. });
  9. test('should convert to false', () => {
  10. expect(toBoolean(undefined)).toBe(false);
  11. expect(toBoolean(null)).toBe(false);
  12. expect(toBoolean('false')).toBe(false);
  13. expect(toBoolean(0)).toBe(false);
  14. });
  15. });
  16. });