# frozen_string_literal: true
require 'spec_helper'
RSpec.describe AutoHtml::Image do
it 'transforms an image link to image tag' do
result = subject.call('https://example.org/images/rails.png')
expect(result).to eq('')
end
it 'transforms image link with a param to image tag' do
result = subject.call('http://farm4.static.flickr.com/3664/3512431377_71b8d002ef.jpg?v=0')
expect(result).to eq('')
end
it 'transforms image link on https to image tag' do
result = subject.call('https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png')
expect(result).to eq('')
end
it 'transforms image link to a image tag with proxy as source' do
filter = AutoHtml::Image.new(proxy: 'https://proxy/?url=')
result = filter.call('http://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png')
expect(result).to eq('')
end
it 'does not transforms already transformed image' do
result = subject.call('')
expect(result).to eq('')
end
it 'transforms an image link within text to image tag' do
result = subject.call('Which do you prefer, this one http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG, or this one https://example.org/images/rails.png?')
expect(result).to eq('Which do you prefer, this one , or this one ?')
end
it 'transforms an image link with a lot of param to image tag' do
result = subject.call('http://tbn3.google.com/images?q=tbn:vS-jtEi9Xc8K6M:http://upload.wikimedia.org/wikipedia/commons/b/ba/Potturinn.jpeg')
expect(result).to eq('')
end
end