2023-03-05 02:58:11 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 15:12:25 +10:00
|
|
|
RSpec.describe SettingsHelper do
|
2023-03-05 02:58:11 +11:00
|
|
|
describe 'session_device_icon' do
|
|
|
|
context 'with a mobile device' do
|
|
|
|
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (iPhone)') }
|
|
|
|
|
|
|
|
it 'detects the device and returns a descriptive string' do
|
|
|
|
result = helper.session_device_icon(session)
|
|
|
|
|
2024-08-20 21:52:45 +10:00
|
|
|
expect(result).to eq('smartphone')
|
2023-03-05 02:58:11 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a tablet device' do
|
|
|
|
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (iPad)') }
|
|
|
|
|
|
|
|
it 'detects the device and returns a descriptive string' do
|
|
|
|
result = helper.session_device_icon(session)
|
|
|
|
|
|
|
|
expect(result).to eq('tablet')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a desktop device' do
|
|
|
|
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (Macintosh)') }
|
|
|
|
|
|
|
|
it 'detects the device and returns a descriptive string' do
|
|
|
|
result = helper.session_device_icon(session)
|
|
|
|
|
2024-08-20 21:52:45 +10:00
|
|
|
expect(result).to eq('desktop_mac')
|
2023-03-05 02:58:11 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|