added auth strategies migration, fixed rebuild of modules on migrations

This commit is contained in:
dswbx
2025-02-27 10:08:22 +01:00
parent 7743f71a11
commit dd48962901
10 changed files with 854 additions and 33 deletions

View File

@@ -0,0 +1,54 @@
import { describe, expect, mock, test } from "bun:test";
import type { ModuleBuildContext } from "../../src";
import { type App, createApp } from "../../src/App";
import * as proto from "../../src/data/prototype";
describe("App", () => {
test("seed includes ctx and app", async () => {
const called = mock(() => null);
await createApp({
options: {
seed: async ({ app, ...ctx }) => {
called();
expect(app).toBeDefined();
expect(ctx).toBeDefined();
expect(Object.keys(ctx)).toEqual([
"connection",
"server",
"em",
"emgr",
"guard",
"flags",
"logger",
]);
},
},
}).build();
expect(called).toHaveBeenCalled();
const app = createApp({
initialConfig: {
data: proto
.em({
todos: proto.entity("todos", {
title: proto.text(),
}),
})
.toJSON(),
},
options: {
//manager: { verbosity: 2 },
seed: async ({ app, ...ctx }: ModuleBuildContext & { app: App }) => {
await ctx.em.mutator("todos").insertOne({ title: "ctx" });
await app.getApi().data.createOne("todos", { title: "api" });
},
},
});
await app.build();
const todos = await app.getApi().data.readMany("todos");
expect(todos.length).toBe(2);
expect(todos[0].title).toBe("ctx");
expect(todos[1].title).toBe("api");
});
});