statuses_helper_spec.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe StatusesHelper do
  4. describe 'status_text_summary' do
  5. context 'with blank text' do
  6. let(:status) { Status.new(spoiler_text: '') }
  7. it 'returns immediately with nil' do
  8. result = helper.status_text_summary(status)
  9. expect(result).to be_nil
  10. end
  11. end
  12. context 'with present text' do
  13. let(:status) { Status.new(spoiler_text: 'SPOILERS!!!') }
  14. it 'returns the content warning' do
  15. result = helper.status_text_summary(status)
  16. expect(result).to eq(I18n.t('statuses.content_warning', warning: 'SPOILERS!!!'))
  17. end
  18. end
  19. end
  20. describe '#media_summary' do
  21. it 'describes the media on a status' do
  22. status = Fabricate :status
  23. Fabricate :media_attachment, status: status, type: :video
  24. Fabricate :media_attachment, status: status, type: :audio
  25. Fabricate :media_attachment, status: status, type: :image
  26. result = helper.media_summary(status)
  27. expect(result).to eq('Attached: 1 image · 1 video · 1 audio')
  28. end
  29. end
  30. describe 'visibility_icon' do
  31. context 'with a status that is public' do
  32. let(:status) { Status.new(visibility: 'public') }
  33. it 'returns the correct fa icon' do
  34. result = helper.visibility_icon(status)
  35. expect(result).to match('globe')
  36. end
  37. end
  38. context 'with a status that is unlisted' do
  39. let(:status) { Status.new(visibility: 'unlisted') }
  40. it 'returns the correct fa icon' do
  41. result = helper.visibility_icon(status)
  42. expect(result).to match('lock_open')
  43. end
  44. end
  45. context 'with a status that is private' do
  46. let(:status) { Status.new(visibility: 'private') }
  47. it 'returns the correct fa icon' do
  48. result = helper.visibility_icon(status)
  49. expect(result).to match('lock')
  50. end
  51. end
  52. context 'with a status that is direct' do
  53. let(:status) { Status.new(visibility: 'direct') }
  54. it 'returns the correct fa icon' do
  55. result = helper.visibility_icon(status)
  56. expect(result).to match('alternate_email')
  57. end
  58. end
  59. end
  60. end