-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(mikro-orm): align with the changes introduced in the mikro-o…
…rm/mikro-orm#4231 closes #2292
- Loading branch information
Showing
8 changed files
with
76 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
packages/orm/mikro-orm/test/helpers/services/EventSubscriber2.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/orm/mikro-orm/test/helpers/services/UnmanagedEventSubscriber1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {EventSubscriber, TransactionEventArgs} from "@mikro-orm/core"; | ||
import {$log, Logger} from "@tsed/logger"; | ||
import {Inject} from "@tsed/di"; | ||
|
||
export class UnmanagedEventSubscriber1 implements EventSubscriber { | ||
constructor(@Inject() private readonly logger: Logger) {} | ||
|
||
public afterFlush(_: TransactionEventArgs): Promise<void> { | ||
$log.info("Changes has been flushed."); | ||
return Promise.resolve(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/orm/mikro-orm/test/helpers/services/UnmanagedEventSubscriber2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {EventSubscriber, TransactionEventArgs} from "@mikro-orm/core"; | ||
import {$log, Logger} from "@tsed/logger"; | ||
import {Inject} from "@tsed/di"; | ||
|
||
export class UnmanagedEventSubscriber2 implements EventSubscriber { | ||
@Inject() | ||
private readonly logger: Logger; | ||
|
||
public afterFlush(_: TransactionEventArgs): Promise<void> { | ||
$log.info("Changes has been flushed."); | ||
return Promise.resolve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ import {Server} from "./helpers/Server"; | |
import {UserService} from "./helpers/services/UserService"; | ||
import {MikroORM} from "@mikro-orm/core"; | ||
import {anything, spy, verify} from "ts-mockito"; | ||
import {EventSubscriber2} from "./helpers/services/EventSubscriber2"; | ||
import {UnmanagedEventSubscriber1} from "./helpers/services/UnmanagedEventSubscriber1"; | ||
import {UnmanagedEventSubscriber2} from "./helpers/services/UnmanagedEventSubscriber2"; | ||
import {MikroOrmModule, TransactionalInterceptor} from "../src"; | ||
|
||
describe("MikroOrm integration", () => { | ||
|
@@ -21,7 +22,7 @@ describe("MikroOrm integration", () => { | |
clientUrl, | ||
type: "mongo", | ||
entities: [User], | ||
subscribers: [new EventSubscriber2()] | ||
subscribers: [UnmanagedEventSubscriber1, new UnmanagedEventSubscriber2()] | ||
}, | ||
{ | ||
clientUrl, | ||
|
@@ -78,6 +79,6 @@ describe("MikroOrm integration", () => { | |
|
||
await service.create({email: "[email protected]"}); | ||
|
||
verify(spiedLogger.info("Changes has been flushed.")).twice(); | ||
verify(spiedLogger.info("Changes has been flushed.")).thrice(); | ||
}); | ||
}); |