BigW Consortium Gitlab

u2f_helper_spec.rb 1.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
require 'spec_helper'

describe U2fHelper do
  describe 'when not on mobile' do
    it 'does not inject u2f on chrome 40' do
      device = double(mobile?: false)
      browser = double(chrome?: true, opera?: false, version: 40, device: device)
      allow(helper).to receive(:browser).and_return(browser)
      expect(helper.inject_u2f_api?).to eq false
    end

    it 'injects u2f on chrome 41' do
      device = double(mobile?: false)
      browser = double(chrome?: true, opera?: false, version: 41, device: device)
      allow(helper).to receive(:browser).and_return(browser)
      expect(helper.inject_u2f_api?).to eq true
    end

    it 'does not inject u2f on opera 39' do
      device = double(mobile?: false)
      browser = double(chrome?: false, opera?: true, version: 39, device: device)
      allow(helper).to receive(:browser).and_return(browser)
      expect(helper.inject_u2f_api?).to eq false
    end

    it 'injects u2f on opera 40' do
      device = double(mobile?: false)
      browser = double(chrome?: false, opera?: true, version: 40, device: device)
      allow(helper).to receive(:browser).and_return(browser)
      expect(helper.inject_u2f_api?).to eq true
    end
  end

  describe 'when on mobile' do
    it 'does not inject u2f on chrome 41' do
      device = double(mobile?: true)
      browser = double(chrome?: true, opera?: false, version: 41, device: device)
      allow(helper).to receive(:browser).and_return(browser)
      expect(helper.inject_u2f_api?).to eq false
    end

    it 'does not inject u2f on opera 40' do
      device = double(mobile?: true)
      browser = double(chrome?: false, opera?: true, version: 40, device: device)
      allow(helper).to receive(:browser).and_return(browser)
      expect(helper.inject_u2f_api?).to eq false
    end
  end
end