Files
archived-next-auth/packages/adapter-mikro-orm/tests/schema.test.ts
Balázs Orbán fdd5e2390d chore: format
2022-12-23 14:42:37 +01:00

29 lines
850 B
TypeScript

import { MikroORM, Options } from "@mikro-orm/core"
import { SqliteDriver } from "@mikro-orm/sqlite"
import { defaultEntities } from "../src"
const config: Options<SqliteDriver> = {
dbName: "./db.sqlite",
type: "sqlite",
entities: [
defaultEntities.User,
defaultEntities.Account,
defaultEntities.Session,
defaultEntities.VerificationToken,
],
}
it("run migrations", async () => {
const orm = await MikroORM.init(config)
await orm.getSchemaGenerator().dropSchema()
const createSchemaSQL = await orm.getSchemaGenerator().getCreateSchemaSQL()
expect(createSchemaSQL).toMatchSnapshot("createSchemaSQL")
const targetSchema = await orm.getSchemaGenerator().getTargetSchema()
expect(targetSchema).toMatchSnapshot("targetSchema")
await orm.getSchemaGenerator().dropSchema()
await orm.close().catch(() => null)
})