Created
July 3, 2018 12:25
-
-
Save ben-ole/ff8df40d0487246b7dc14c1d2bef4078 to your computer and use it in GitHub Desktop.
KaufmannEx TestSupport
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
defmodule Sample.EventHandlerTest do | |
use KaufmannEx.TestSupport.MockBus | |
test "Events Can Be published & observed" do | |
given_event(:"command.user.create", %{user_name: "Test User", user_email: "[email protected]"}) | |
assert %{ | |
payload: %{user_id: uknown_id} | |
} = then_event(:"event.test") | |
end | |
test "Effects of consumed events can be observed" do | |
given_event(:"command.user.create", %{user_name: "Test User", user_email: "[email protected]"}) | |
assert Sample.User.user_exists?("[email protected]") | |
end | |
test "other actions that trigger events can be tested" do | |
Sample.SomeModule.update_user(id: 1, name: "George") | |
assert %{payload: %{name: "George" }} = then_event(:"command.user.update") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment