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.

19 lines (14 loc) 988 B
import { ArrayType } from '@mikro-orm/core'; import { MongoPlatform } from '@mikro-orm/mongodb'; describe('ArrayType', () => { const type = new ArrayType(); const platform = new MongoPlatform(); test('convertToDatabaseValue', () => { expect(type.convertToDatabaseValue(['a'], platform)).toStrictEqual(['a'] as any); expect(type.convertToDatabaseValue(null, platform)).toStrictEqual(null); expect(type.convertToDatabaseValue(undefined as any, platform)).toBe(undefined); expect(() => type.convertToDatabaseValue(1 as any, platform)).toThrow(`Could not convert JS value '1' of type 'number' to type ArrayType`); // expect(() => type.convertToDatabaseValue('2000-01-01', platform)).toThrow(`Could not convert JS value '2000-01-01' of type 'string' to type ArrayType`); // 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 ArrayType`); }); });