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.
31 lines (23 loc) • 1.06 kB
text/typescript
import { Configuration } from '@mikro-orm/core';
import { CLIHelper } from '@mikro-orm/cli';
import { MongoDriver } from '@mikro-orm/mongodb';
const close = jest.fn();
const config = new Configuration({ driver: MongoDriver } as any, false);
const connection = { loadFile: jest.fn() };
const em = { getConnection: () => connection };
const showHelpMock = jest.spyOn(CLIHelper, 'showHelp');
showHelpMock.mockImplementation(() => void 0);
const getORMMock = jest.spyOn(CLIHelper, 'getORM');
getORMMock.mockResolvedValue({ em, config, close } as any);
const dumpMock = jest.spyOn(CLIHelper, 'dump');
dumpMock.mockImplementation(() => void 0);
(global as any).console.log = jest.fn();
import { ImportCommand } from '../../../packages/cli/src/commands/ImportCommand';
describe('ImportDatabaseCommand', () => {
test('handler', async () => {
const cmd = new ImportCommand();
await expect(cmd.handler({} as any)).resolves.toBeUndefined();
expect(close).toHaveBeenCalledTimes(1);
expect(connection.loadFile.mock.calls.length).toBe(1);
});
});