Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Dec 18, 2024
1 parent 8844b21 commit bb0c432
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
29 changes: 12 additions & 17 deletions packages/core/utils/src/dml/__tests__/entity-builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3019,6 +3019,7 @@ describe("Entity builder", () => {
persist: false,
name: "user_id",
nullable: false,
formula: expect.any(Function),
reference: "scalar",
setter: false,
type: "string",
Expand Down Expand Up @@ -3132,6 +3133,7 @@ describe("Entity builder", () => {
type: "string",
reference: "scalar",
name: "email_id",
formula: expect.any(Function),
nullable: false,
persist: false,
getter: false,
Expand Down Expand Up @@ -3244,6 +3246,7 @@ describe("Entity builder", () => {
type: "string",
reference: "scalar",
name: "emails_id",
formula: expect.any(Function),
nullable: true,
persist: false,
getter: false,
Expand Down Expand Up @@ -3347,6 +3350,7 @@ describe("Entity builder", () => {
type: "string",
reference: "scalar",
name: "email_id",
formula: expect.any(Function),
nullable: false,
persist: false,
getter: false,
Expand Down Expand Up @@ -3454,6 +3458,7 @@ describe("Entity builder", () => {
type: "string",
reference: "scalar",
name: "email_id",
formula: expect.any(Function),
nullable: false,
persist: false,
getter: false,
Expand Down Expand Up @@ -3630,6 +3635,7 @@ describe("Entity builder", () => {
columnType: "text",
type: "string",
reference: "scalar",
formula: expect.any(Function),
name: "email_id",
nullable: false,
persist: false,
Expand Down Expand Up @@ -3716,6 +3722,7 @@ describe("Entity builder", () => {
name: "user_id",
nullable: false,
reference: "scalar",
formula: expect.any(Function),
setter: false,
type: "string",
persist: false,
Expand Down Expand Up @@ -4662,6 +4669,7 @@ describe("Entity builder", () => {
reference: "scalar",
persist: false,
type: "string",
formula: expect.any(Function),
columnType: "text",
nullable: false,
name: "user_id",
Expand Down Expand Up @@ -4862,6 +4870,7 @@ describe("Entity builder", () => {
type: "string",
columnType: "text",
nullable: true,
formula: expect.any(Function),
name: "user_id",
getter: false,
setter: false,
Expand Down Expand Up @@ -5282,23 +5291,6 @@ describe("Entity builder", () => {
})
})

test("throw error when other side relationship is missing", () => {
const email = model.define("email", {
email: model.text(),
isVerified: model.boolean(),
user: model.belongsTo(() => user),
})

const user = model.define("user", {
id: model.number(),
username: model.text(),
})

expect(() => toMikroORMEntity(email)).toThrow(
'Missing property "email" on "User" entity. Make sure to define it as a relationship'
)
})

test("throw error when other side relationship is invalid", () => {
const email = model.define("email", {
email: model.text(),
Expand Down Expand Up @@ -5497,6 +5489,7 @@ describe("Entity builder", () => {
type: "string",
persist: false,
columnType: "text",
formula: expect.any(Function),
nullable: false,
name: "user_id",
getter: false,
Expand Down Expand Up @@ -5698,6 +5691,7 @@ describe("Entity builder", () => {
type: "string",
columnType: "text",
nullable: false,
formula: expect.any(Function),
name: "user_id",
getter: false,
setter: false,
Expand Down Expand Up @@ -5920,6 +5914,7 @@ describe("Entity builder", () => {
type: "string",
columnType: "text",
reference: "scalar",
formula: expect.any(Function),
persist: false,
getter: false,
setter: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,6 @@ export function defineBelongsToRelationship(
relationship.options.foreignKeyName ??
camelToSnakeCase(`${relationship.name}Id`)

Object.defineProperty(MikroORMEntity.prototype, foreignKeyName, {
value: null,
configurable: true,
enumerable: true,
writable: true,
})

Property({
columnType: "text",
type: "string",
Expand Down

0 comments on commit bb0c432

Please sign in to comment.