UNPKG

undeexcepturi

Version:

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.

23 lines (17 loc) 1.07 kB
import { TimeType } from '@mikro-orm/core'; import { MongoPlatform } from '@mikro-orm/mongodb'; describe('TimeType', () => { const type = new TimeType(); const platform = new MongoPlatform(); test('convertToDatabaseValue', () => { expect(type.convertToDatabaseValue('00:00:01', platform)).toBe('00:00:01'); expect(type.convertToDatabaseValue(null, platform)).toBe(null); expect(type.convertToDatabaseValue(undefined, platform)).toBe(undefined); expect(() => type.convertToDatabaseValue(1, platform)).toThrow(`Could not convert JS value '1' of type 'number' to type TimeType`); expect(() => type.convertToDatabaseValue('2000-01-01', platform)).toThrow(`Could not convert JS value '2000-01-01' of type 'string' to type TimeType`); expect(() => type.convertToDatabaseValue(new Date('2000-01-01'), platform)).toThrow(`Could not convert JS value '2000-01-01T00:00:00.000Z' of type 'date' to type TimeType`); }); test('getColumnType', () => { expect(type.getColumnType({ columnType: 'asd' } as any, platform)).toBe('time'); }); });