From 0ff8a04f2c4c694bfffa119cb7f0f9bcdac3c9dd Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 29 Jul 2021 17:27:38 +0200 Subject: [PATCH] Add docs for listener test --- .../doc/development/events-and-listeners.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/content/doc/development/events-and-listeners.md b/docs/content/doc/development/events-and-listeners.md index 46f5c0896..091a5fb00 100644 --- a/docs/content/doc/development/events-and-listeners.md +++ b/docs/content/doc/development/events-and-listeners.md @@ -193,3 +193,19 @@ This prevents any events from being fired and lets you assert an event has been {{< highlight golang >}} events.AssertDispatched(t, &TaskCreatedEvent{}) {{< /highlight >}} + +### Testing a listener + +You can call an event listener manually with the `events.TestListener` method like so: + +{{< highlight golang >}} +ev := &TaskCommentCreatedEvent{ + Task: &task, + Doer: u, + Comment: tc, +} + +events.TestListener(t, ev, &SendTaskCommentNotification{}) +{{< /highlight >}} + +This will call the listener's `Handle` method and assert it did not return an error when calling.