From 6d1a8c92eccfab0922ee5e80bdc893b4c08d51bb Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Sun, 12 Nov 2023 03:08:14 +0500 Subject: [PATCH] #1448, add specs --- spec/helpers/social_helper_spec.rb | 10 ++++++++++ spec/views/actions/_share.html.haml_spec.rb | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/helpers/social_helper_spec.rb b/spec/helpers/social_helper_spec.rb index b56d6ab3..7583e0de 100644 --- a/spec/helpers/social_helper_spec.rb +++ b/spec/helpers/social_helper_spec.rb @@ -30,4 +30,14 @@ describe SocialHelper, type: :helper do URL end end + + describe "#answer_copy_content" do + subject { answer_copy_content(answer) } + + it "returns a formatted content to copy" do + expectedContent = "#{answer.question.content} - #{answer.content} [https://example.com/@#{answer.user.screen_name}/a/#{answer.id}]" + + expect(subject).to eq(expectedContent) + end + end end diff --git a/spec/views/actions/_share.html.haml_spec.rb b/spec/views/actions/_share.html.haml_spec.rb index f3dfc49f..cdef7387 100644 --- a/spec/views/actions/_share.html.haml_spec.rb +++ b/spec/views/actions/_share.html.haml_spec.rb @@ -24,6 +24,10 @@ describe "actions/_share.html.haml", type: :view do end it "has a dropdown item to share to anywhere else" do - expect(rendered).to have_css(%(a.dropdown-item[data-controller="share"])) + expect(rendered).to have_css(%(a.dropdown-item[data-action="share#share"])) + end + + it "has a dropdown item to copy to clipboard" do + expect(rendered).to have_css(%(a.dropdown-item[data-action="share#copyToClipboard"])) end end