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

static_menu_spec.rb « sidebars « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fda953c0791ecf5092e16007515ea475814cc2bb (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::StaticMenu, feature_category: :navigation do
  let(:context) { {} }

  subject { described_class.new(context) }

  describe '#serialize_for_super_sidebar' do
    it 'returns flat list of all menu items' do
      subject.add_item(Sidebars::MenuItem.new(item_id: 'id1', title: 'Is active', link: 'foo2',
        active_routes: { controller: 'fooc' }))
      subject.add_item(Sidebars::MenuItem.new(item_id: 'id2', title: 'Not active', link: 'foo3',
        active_routes: { controller: 'barc' }))
      subject.add_item(Sidebars::NilMenuItem.new(item_id: 'nil_item'))

      allow(context).to receive(:route_is_active).and_return(->(x) { x[:controller] == 'fooc' })

      expect(subject.serialize_for_super_sidebar).to eq(
        [
          {
            id: 'id1',
            title: "Is active",
            icon: nil,
            avatar: nil,
            entity_id: nil,
            link: "foo2",
            is_active: true,
            pill_count: nil,
            link_classes: nil
          },
          {
            id: 'id2',
            title: "Not active",
            icon: nil,
            avatar: nil,
            entity_id: nil,
            link: "foo3",
            is_active: false,
            pill_count: nil,
            link_classes: nil
          }
        ]
      )
    end
  end
end