Skip to content

Commit

Permalink
Add component spec for ImageInput
Browse files Browse the repository at this point in the history
  • Loading branch information
tillprochaska committed May 21, 2022
1 parent 1e94637 commit cd04f6d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion spec/components/image_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@

RSpec.describe ImageInput::ImageInput, type: :component do
subject { render_inline(described_class.new(**params)) }
let(:params) { { id: :logo } }

let(:params) { {} }
it { should have_css('.ImageInput') }
it { should have_css('input[type="file"][id="logo"][name="logo"][hidden]', visible: :all) }

context 'without existing upload' do
it { should have_text('Noch kein Bild hochgeladen') }
it { should have_css('svg.Icon') }
it { should have_button('Bild hochladen') }
it { should_not have_css('.ImageInput-selectedImage') }
end

context 'with existing upload' do
let(:file) { fixture_file_upload('example-image.png') }
let(:blob) { ActiveStorage::Blob.create_and_upload!(io: file, filename: file.original_filename) }

let(:params) { { id: :logo, value: blob } }

it { should have_text('example-image.png') }
it { should have_css('img[src$="/example-image.png"]') }
it { should have_button('Bild ersetzen') }
it { should_not have_css('.ImageInput-emptyState') }
end
end

0 comments on commit cd04f6d

Please sign in to comment.