mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
feat: introduce DummyConnection class for testing purposes
This commit is contained in:
@@ -230,3 +230,15 @@ export function customIntrospector<T extends Constructor<Dialect>>(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class DummyConnection extends Connection {
|
||||||
|
override name = "dummy";
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(undefined as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getFieldSchema(): SchemaResponse {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, it, expect } from "bun:test";
|
import { describe, it, expect } from "bun:test";
|
||||||
import { EntityTypescript } from "./EntityTypescript";
|
import { EntityTypescript } from "./EntityTypescript";
|
||||||
import * as proto from "../prototype";
|
import * as proto from "../prototype";
|
||||||
import { getDummyConnection } from "../../../__test__/data/helper";
|
import { DummyConnection } from "../connection/Connection";
|
||||||
|
|
||||||
describe("EntityTypescript", () => {
|
describe("EntityTypescript", () => {
|
||||||
it("should generate correct typescript for system entities", () => {
|
it("should generate correct typescript for system entities", () => {
|
||||||
@@ -18,8 +18,7 @@ describe("EntityTypescript", () => {
|
|||||||
relation(test).manyToOne(users);
|
relation(test).manyToOne(users);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { dummyConnection } = getDummyConnection();
|
const et = new EntityTypescript(schema.proto.withConnection(new DummyConnection()));
|
||||||
const et = new EntityTypescript(schema.proto.withConnection(dummyConnection));
|
|
||||||
expect(et.toString()).toContain('users?: DB["users"];');
|
expect(et.toString()).toContain('users?: DB["users"];');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user