Skip to content

Commit ac1c2b4

Browse files
committed
Add tests and bump version
1 parent abfacb2 commit ac1c2b4

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule WebPushEncryption.Mixfile do
22
use Mix.Project
33

4-
@version "0.2.1"
4+
@version "0.2.2"
55

66
def project do
77
[

test/test_helper.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ExUnit.start()
22

33
defmodule Fixtures do
44
@gcm_url "https://android.googleapis.com/gcm/send"
5+
@fcm_url "https://fcm.googleapis.com/fcm/send"
56

67
def example_input(), do: "Hello, World."
78
def example_output(), do: "CE2OS6BxfXsC2YbTdfkeWLlt4AKWbHZ3Fe53n5/4Yg=="
@@ -28,6 +29,10 @@ defmodule Fixtures do
2829
def valid_gcm_subscription() do
2930
Map.put(valid_subscription(), :endpoint, @gcm_url)
3031
end
32+
33+
def valid_fcm_subscription() do
34+
Map.put(valid_subscription(), :endpoint, @fcm_url)
35+
end
3136
end
3237

3338
defmodule HTTPoisonSandbox do

test/web_push_encryption/push_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,15 @@ defmodule WebPushEncryption.PushTest do
2828
Push.send_web_push(Fixtures.example_input(), Fixtures.valid_gcm_subscription(), "auth_token")
2929
assert Enum.count(HTTPoisonSandbox.requests()) == 1
3030
end
31+
32+
test "fcm endpoint without auth_token" do
33+
assert_raise ArgumentError, fn ->
34+
Push.send_web_push(Fixtures.example_input(), Fixtures.valid_fcm_subscription())
35+
end
36+
end
37+
38+
test "fcm endpoint with auth_token" do
39+
Push.send_web_push(Fixtures.example_input(), Fixtures.valid_fcm_subscription(), "auth_token")
40+
assert Enum.count(HTTPoisonSandbox.requests()) == 1
41+
end
3142
end

0 commit comments

Comments
 (0)