Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 4c874e1

Browse files
committed
refactor(notify): test for follow
1 parent 25cb482 commit 4c874e1

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

test/groupher_server/delivery/mention_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ defmodule GroupherServer.Test.Delivery.Mention do
4343
assert mention.user.login == user.login
4444
end
4545

46-
@tag :wip
4746
test "mention multiable times on same article, will only have one record",
4847
~m(post user user2 mention_contents)a do
4948
{:ok, :pass} = Delivery.send(:mention, post, mention_contents, user)

test/groupher_server/delivery/notification_test.exs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,49 @@ defmodule GroupherServer.Test.Delivery.Notification do
3939
|> Repo.update()
4040
end
4141

42-
describe "notification curd" do
42+
describe "account follow" do
43+
@tag :wip
44+
test "support follow action", ~m(user user2)a do
45+
notify_attrs = %{
46+
action: :follow,
47+
user_id: user.id
48+
}
49+
50+
{:ok, _} = Delivery.send(:notify, notify_attrs, user2)
51+
52+
{:ok, paged_notifies} = Delivery.fetch(:notification, user.id, %{page: 1, size: 10})
53+
54+
assert paged_notifies.total_count == 1
55+
notify = paged_notifies.entries |> List.first()
56+
57+
assert notify.action == "FOLLOW"
58+
assert notify.user_id == user.id
59+
assert user2 |> user_exist_in?(notify.from_users)
60+
end
61+
62+
@tag :wip
63+
test "similar follow notify should be merged", ~m(user user2 user3)a do
64+
notify_attrs = %{
65+
action: :follow,
66+
user_id: user.id
67+
}
68+
69+
{:ok, _} = Delivery.send(:notify, notify_attrs, user2)
70+
{:ok, _} = Delivery.send(:notify, notify_attrs, user3)
71+
72+
{:ok, paged_notifies} = Delivery.fetch(:notification, user.id, %{page: 1, size: 10})
73+
74+
notify = paged_notifies.entries |> List.first()
75+
76+
assert paged_notifies.total_count == 1
77+
78+
assert notify.from_users |> length == 2
79+
assert user2 |> user_exist_in?(notify.from_users)
80+
assert user3 |> user_exist_in?(notify.from_users)
81+
end
82+
end
83+
84+
describe "notification" do
4385
test "similar notify should be merged", ~m(user user2 user3 notify_attrs)a do
4486
{:ok, _} = Delivery.send(:notify, notify_attrs, user2)
4587
{:ok, _} = Delivery.send(:notify, notify_attrs, user3)

0 commit comments

Comments
 (0)