-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(email-plugin): Only call
loadData()
function after filters run
Fixes #518
- Loading branch information
1 parent
ef99c22
commit e22db7e
Showing
3 changed files
with
32 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -421,6 +421,24 @@ describe('EmailPlugin', () => { | |
expect(onSend.mock.calls[0][0].from).toBe('"test from" <[email protected]>'); | ||
expect(onSend.mock.calls[0][0].recipient).toBe('[email protected]'); | ||
}); | ||
|
||
it('only executes for filtered events', async () => { | ||
let callCount = 0; | ||
const handler = new EmailEventListener('test') | ||
.on(MockEvent) | ||
.filter(event => event.shouldSend === true) | ||
.loadData(async ({ injector }) => { | ||
callCount++; | ||
}); | ||
|
||
await initPluginWithHandlers([handler]); | ||
|
||
eventBus.publish(new MockEvent(RequestContext.empty(), false)); | ||
eventBus.publish(new MockEvent(RequestContext.empty(), true)); | ||
await pause(); | ||
|
||
expect(callCount).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('orderConfirmationHandler', () => { | ||
|
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