Skip to content

Commit

Permalink
Modify test file to fix default title display for likes
Browse files Browse the repository at this point in the history
  • Loading branch information
gith-u-b authored and huacnlee committed Aug 31, 2023
1 parent a60eef4 commit 0b7a35e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/helpers/likes_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ class LikesHelperTest < ActionView::TestCase
test "should result when logined user liked" do
sign_in user
user.like_topic_ids = [topic.id]
assert_equal %(<a title="Unlike" data-count="0" data-state="active" data-type="Topic" data-id="#{topic.id}" class="likeable active" href="#"><i class='icon fa fa-heart'></i> <span></span></a>), likeable_tag(topic)
assert_equal %(<a title="Like" data-count="0" data-state="active" data-type="Topic" data-id="#{topic.id}" class="likeable active" href="#"><i class='icon fa fa-heart'></i> <span></span></a>), likeable_tag(topic)

topic.likes_count = 3
assert_equal %(<a title="Unlike" data-count="3" data-state="active" data-type="Topic" data-id="#{topic.id}" class="likeable active" href="#"><i class='icon fa fa-heart'></i> <span>3 likes</span></a>), likeable_tag(topic)
assert_equal %(<a title="Like" data-count="3" data-state="active" data-type="Topic" data-id="#{topic.id}" class="likeable active" href="#"><i class='icon fa fa-heart'></i> <span>3 likes</span></a>), likeable_tag(topic)
end

test "should result when unlogin user" do
assert_equal %(<a title="Unlike" data-count="0" data-state="deactive" data-type="Topic" data-id="#{topic.id}" class="likeable deactive" href="#"><i class='icon fa fa-heart'></i> <span></span></a>), likeable_tag(topic)
assert_equal %(<a title="Like" data-count="0" data-state="deactive" data-type="Topic" data-id="#{topic.id}" class="likeable deactive" href="#"><i class='icon fa fa-heart'></i> <span></span></a>), likeable_tag(topic)
end

test "should result with no_cache params" do
str = %(<a title="Unlike" data-count="0" data-state="deactive" data-type="Topic" data-id="#{topic.id}" class="likeable deactive" href="#"><i class='icon fa fa-heart'></i> <span></span></a>)
str = %(<a title="Like" data-count="0" data-state="deactive" data-type="Topic" data-id="#{topic.id}" class="likeable deactive" href="#"><i class='icon fa fa-heart'></i> <span></span></a>)
sign_in user
assert_equal str, likeable_tag(topic, cache: true)
end

test "should allow addition class" do
sign_in user
assert_equal %(<a title="Unlike" data-count="0" data-state="deactive" data-type="Reply" data-id="#{reply.id}" class="likeable deactive btn btn-secondary" href="#"><i class='icon fa fa-heart'></i> <span></span></a>), likeable_tag(reply, class: "btn btn-secondary")
assert_equal %(<a title="Like" data-count="0" data-state="deactive" data-type="Reply" data-id="#{reply.id}" class="likeable deactive btn btn-secondary" href="#"><i class='icon fa fa-heart'></i> <span></span></a>), likeable_tag(reply, class: "btn btn-secondary")
end
end

0 comments on commit 0b7a35e

Please sign in to comment.