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

helper_spec.rb « docs « tracking « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f7965502f1cc431e1d0fd91f80d4feb13f478a8 (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
86
87
88
89
90
91
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Tracking::Docs::Helper do
  let_it_be(:klass) do
    Class.new do
      include Gitlab::Tracking::Docs::Helper
    end
  end

  describe '#auto_generated_comment' do
    it 'renders information about missing description' do
      expect(klass.new.auto_generated_comment).to match /This documentation is auto generated by a script/
    end
  end

  describe '#render_description' do
    context 'description is empty' do
      it 'renders information about missing description' do
        object = double(description: '')

        expect(klass.new.render_description(object)).to eq('Missing description')
      end
    end

    context 'description is present' do
      it 'render description' do
        object = double(description: 'some description')

        expect(klass.new.render_description(object)).to eq('some description')
      end
    end
  end

  describe '#render_event_taxonomy' do
    it 'render table with event taxonomy' do
      attributes = {
        category: 'epics',
        action: 'promote',
        label: nil,
        property_description: 'String with issue id',
        value_description: 'Integer issue id'
      }
      object = double(attributes: attributes)
      event_taxonomy = <<~MD.chomp
        | category | action | label | property | value |
        |---|---|---|---|---|
        | `epics` | `promote` | `` | `String with issue id` | `Integer issue id` |
      MD

      expect(klass.new.render_event_taxonomy(object)).to eq(event_taxonomy)
    end
  end

  describe '#md_link_to' do
    it 'render link in md format' do
      expect(klass.new.md_link_to('zelda', 'link')).to eq('[zelda](link)')
    end
  end

  describe '#render_owner' do
    it 'render information about group owning event' do
      object = double(product_group: "group::product intelligence")

      expect(klass.new.render_owner(object)).to eq("Owner: `group::product intelligence`")
    end
  end

  describe '#render_tiers' do
    it 'render information about tiers' do
      object = double(tiers: %w[bronze silver gold])

      expect(klass.new.render_tiers(object)).to eq("Tiers: `bronze`, `silver`, `gold`")
    end
  end

  describe '#render_yaml_definition_path' do
    it 'render relative location of yaml definition' do
      object = double(yaml_path: 'config/events/button_click.yaml')

      expect(klass.new.render_yaml_definition_path(object)).to eq("YAML definition: `config/events/button_click.yaml`")
    end
  end

  describe '#backtick' do
    it 'wraps string in backticks chars' do
      expect(klass.new.backtick('test')).to eql("`test`")
    end
  end
end