account_moderation_notes_helper_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Admin::AccountModerationNotesHelper do
  4. include AccountsHelper
  5. describe '#admin_account_link_to' do
  6. subject { helper.admin_account_link_to(account) }
  7. context 'when Account is nil' do
  8. let(:account) { nil }
  9. it 'returns nil' do
  10. expect(subject).to be_nil
  11. end
  12. end
  13. context 'with account' do
  14. let(:account) { Fabricate(:account) }
  15. it 'returns a labeled avatar link to the account' do
  16. expect(parsed_html.a[:href]).to eq admin_account_path(account.id)
  17. expect(parsed_html.a[:class]).to eq 'name-tag'
  18. expect(parsed_html.a.span.text).to eq account.acct
  19. end
  20. end
  21. end
  22. describe '#admin_account_inline_link_to' do
  23. subject { helper.admin_account_inline_link_to(account) }
  24. context 'when Account is nil' do
  25. let(:account) { nil }
  26. it 'returns nil' do
  27. expect(subject).to be_nil
  28. end
  29. end
  30. context 'with account' do
  31. let(:account) { Fabricate(:account) }
  32. it 'returns an inline link to the account' do
  33. expect(parsed_html.a[:href]).to eq admin_account_path(account.id)
  34. expect(parsed_html.a[:class]).to eq 'inline-name-tag'
  35. expect(parsed_html.a.span.text).to eq account.acct
  36. end
  37. end
  38. end
  39. def parsed_html
  40. Nokogiri::Slop(subject)
  41. end
  42. end