Welcome to mirror list, hosted at ThFree Co, Russian Federation.

learn_gitlab_menu_spec.rb « menus « projects « sidebars « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ef5ae5505517c9bb87e0a1c975ce0c776432faba (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Projects::Menus::LearnGitlabMenu do
  let_it_be(:project) { build(:project) }
  let_it_be(:experiment_enabled) { true }
  let_it_be(:tracking_category) { 'Growth::Activation::Experiment::LearnGitLabB' }

  let(:context) do
    Sidebars::Projects::Context.new(
      current_user: nil,
      container: project,
      learn_gitlab_experiment_enabled: experiment_enabled,
      learn_gitlab_experiment_tracking_category: tracking_category
    )
  end

  subject { described_class.new(context) }

  it 'does not contain any sub menu' do
    expect(subject.has_items?).to be false
  end

  describe '#nav_link_html_options' do
    let_it_be(:data_tracking) do
      {
        class: 'home',
        data: {
          track_action: 'click_menu',
          track_property: tracking_category,
          track_label: 'learn_gitlab'
        }
      }
    end

    specify do
      expect(subject.nav_link_html_options).to eq(data_tracking)
    end
  end

  describe '#render?' do
    context 'when learn gitlab experiment is enabled' do
      it 'returns true' do
        expect(subject.render?).to eq true
      end
    end

    context 'when learn gitlab experiment is disabled' do
      let(:experiment_enabled) { false }

      it 'returns false' do
        expect(subject.render?).to eq false
      end
    end
  end

  describe '#has_pill?' do
    context 'when learn gitlab experiment is enabled' do
      it 'returns true' do
        expect(subject.has_pill?).to eq true
      end
    end

    context 'when learn gitlab experiment is disabled' do
      let(:experiment_enabled) { false }

      it 'returns false' do
        expect(subject.has_pill?).to eq false
      end
    end
  end

  describe '#pill_count' do
    before do
      expect_next_instance_of(LearnGitlab::Onboarding) do |onboarding|
        expect(onboarding).to receive(:completed_percentage).and_return(20)
      end
    end

    it 'returns pill count' do
      expect(subject.pill_count).to eq '20%'
    end
  end
end