PushX.Test.Assertions (PushX v0.15.0)

Copy Markdown View Source

ExUnit assertions for PushX.Test (test delivery mode).

import PushX.Test.Assertions

push = assert_pushed(%{provider: :apns, target: ^token})
assert push.payload["aps"]["alert"]["title"] == "Order shipped"

refute_pushed(%{provider: :fcm, target: ^token})
assert_no_pushes()

Patterns are ordinary match patterns (pins allowed) checked against each recorded PushX.Test.Push.t/0 of the current test process, like assert_receive/1. Failure messages list what was recorded.

Summary

Functions

Asserts that the current test process recorded no pushes at all.

Asserts that at least one recorded push matches pattern and returns the first match. pattern is a match pattern, e.g. %{provider: :apns, target: ^token, instance: nil}.

Asserts that no recorded push matches pattern.

Functions

assert_no_pushes()

(macro)

Asserts that the current test process recorded no pushes at all.

assert_pushed(pattern)

(macro)

Asserts that at least one recorded push matches pattern and returns the first match. pattern is a match pattern, e.g. %{provider: :apns, target: ^token, instance: nil}.

refute_pushed(pattern)

(macro)

Asserts that no recorded push matches pattern.