summaryrefslogtreecommitdiff
path: root/spec/helpers/stat_anchors_helper_spec.rb
blob: 0615baac3cb47d52ed9a178737184988a7d08d78 (plain)
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
50
51
52
53
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe StatAnchorsHelper do
  let(:anchor_klass) { ProjectPresenter::AnchorData }

  describe '#stat_anchor_attrs' do
    subject { helper.stat_anchor_attrs(anchor) }

    context 'when anchor is a link' do
      let(:anchor) { anchor_klass.new(true) }

      it 'returns the proper attributes' do
        expect(subject[:class]).to include('stat-link')
      end
    end

    context 'when anchor is not a link' do
      context 'when class_modifier is set' do
        let(:anchor) { anchor_klass.new(false, nil, nil, 'default') }

        it 'returns the proper attributes' do
          expect(subject[:class]).to include('gl-button btn btn-default')
        end
      end

      context 'when class_modifier is not set' do
        let(:anchor) { anchor_klass.new(false) }

        it 'returns the proper attributes' do
          expect(subject[:class]).to include('gl-button btn btn-dashed')
        end
      end
    end

    context 'when itemprop is not set' do
      let(:anchor) { anchor_klass.new(false, nil, nil, nil, nil, false) }

      it 'returns the itemprop attributes' do
        expect(subject[:itemprop]).to be_nil
      end
    end

    context 'when itemprop is set set' do
      let(:anchor) { anchor_klass.new(false, nil, nil, nil, nil, true) }

      it 'returns the itemprop attributes' do
        expect(subject[:itemprop]).to eq true
      end
    end
  end
end