2023-04-26 18:21:32 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 07:12:25 +02:00
|
|
|
RSpec.describe MediaComponentHelper do
|
2023-12-07 13:15:50 +01:00
|
|
|
before { helper.extend controller_helpers }
|
|
|
|
|
2023-04-26 18:21:32 +02:00
|
|
|
describe 'render_video_component' do
|
|
|
|
let(:media) { Fabricate(:media_attachment, type: :video, status: Fabricate(:status)) }
|
|
|
|
let(:result) { helper.render_video_component(media.status) }
|
|
|
|
|
|
|
|
it 'renders a react component for the video' do
|
|
|
|
expect(parsed_html.div['data-component']).to eq('Video')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'render_audio_component' do
|
|
|
|
let(:media) { Fabricate(:media_attachment, type: :audio, status: Fabricate(:status)) }
|
|
|
|
let(:result) { helper.render_audio_component(media.status) }
|
|
|
|
|
|
|
|
it 'renders a react component for the audio' do
|
|
|
|
expect(parsed_html.div['data-component']).to eq('Audio')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'render_media_gallery_component' do
|
|
|
|
let(:media) { Fabricate(:media_attachment, type: :audio, status: Fabricate(:status)) }
|
|
|
|
let(:result) { helper.render_media_gallery_component(media.status) }
|
|
|
|
|
|
|
|
it 'renders a react component for the media gallery' do
|
|
|
|
expect(parsed_html.div['data-component']).to eq('MediaGallery')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def parsed_html
|
|
|
|
Nokogiri::Slop(result)
|
|
|
|
end
|
2023-12-07 13:15:50 +01:00
|
|
|
|
|
|
|
def controller_helpers
|
|
|
|
Module.new do
|
|
|
|
def current_account = Account.last
|
|
|
|
end
|
|
|
|
end
|
2023-04-26 18:21:32 +02:00
|
|
|
end
|