1
0

media_component_helper_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe MediaComponentHelper do
  4. before { helper.extend controller_helpers }
  5. describe 'render_video_component' do
  6. let(:media) { Fabricate(:media_attachment, type: :video, status: Fabricate(:status)) }
  7. let(:result) { helper.render_video_component(media.status) }
  8. it 'renders a react component for the video' do
  9. expect(parsed_html.div['data-component']).to eq('Video')
  10. end
  11. end
  12. describe 'render_audio_component' do
  13. let(:media) { Fabricate(:media_attachment, type: :audio, status: Fabricate(:status)) }
  14. let(:result) { helper.render_audio_component(media.status) }
  15. it 'renders a react component for the audio' do
  16. expect(parsed_html.div['data-component']).to eq('Audio')
  17. end
  18. end
  19. describe 'render_media_gallery_component' do
  20. let(:media) { Fabricate(:media_attachment, type: :audio, status: Fabricate(:status)) }
  21. let(:result) { helper.render_media_gallery_component(media.status) }
  22. it 'renders a react component for the media gallery' do
  23. expect(parsed_html.div['data-component']).to eq('MediaGallery')
  24. end
  25. end
  26. private
  27. def parsed_html
  28. Nokogiri::Slop(result)
  29. end
  30. def controller_helpers
  31. Module.new do
  32. def current_account = Account.last
  33. end
  34. end
  35. end