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

section_spec.rb « navigation « gitlab « spec - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f71f60f271e7208befbcb211c6a87a300c1b473b (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
# frozen_string_literal: true

require 'spec_helper'
require 'gitlab/navigation/section'
require 'gitlab/navigation/category'

describe Gitlab::Navigation::Section do
  subject(:section) { described_class.new(element) }

  let(:element) do
    {
      section_title: title,
      section_url: url,
      ee_only: ee_only,
      ee_tier: ee_tier,
      section_categories: categories
    }
  end

  let(:title) { 'Title' }
  let(:url) { 'README.html' }
  let(:ee_only) { true }
  let(:ee_tier) { 'GitLab Premium' }
  let(:categories) { [{ category_title: 'Category Title' }] }

  describe '#title' do
    subject { section.title }

    it { is_expected.to eq(title) }
  end

  describe '#url' do
    subject { section.url }

    it { is_expected.to eq(url) }
  end

  describe '#ee_only?' do
    subject { section.ee_only? }

    it { is_expected.to eq(ee_only) }
  end

  describe '#ee_tier' do
    subject { section.ee_tier }

    it { is_expected.to eq(ee_tier) }
  end

  describe '#has_children?' do
    subject { section.has_children? }

    it { is_expected.to be_truthy }

    context 'when categories are empty' do
      let(:categories) { [] }

      it { is_expected.to be_falsey }
    end
  end

  describe '#children' do
    subject { section.children }

    it 'returns a list of children' do
      children = subject

      expect(children.first.title).to eq('Category Title')
    end

    context 'when categories are empty' do
      let(:categories) { [] }

      it { is_expected.to eq([]) }
    end
  end
end