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

badges_spec.rb « filters « lib « spec - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 09d34353cfcf742097282a5a6d07d1ffd30d232f (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
92
93
94
95
96
97
require 'spec_helper'

require 'filters/badges'

describe BadgesFilter do
  describe '#run' do
    let(:content) { nil }

    subject(:run) { described_class.new.run(content) }

    context 'when <strong>(FREE)</strong> badge' do
      let(:content) { '<strong>(FREE)</strong>' }

      it 'returns correct HTML' do
        expect(run).to eq('<span data-component="docs-badges"><span data-type="tier" data-value="free"></span></span>')
      end
    end

    context 'when <strong>(FREE SELF)</strong> badge' do
      let(:content) { '<strong>(FREE SELF)</strong>' }

      it 'returns correct HTML' do
        expect(run).to eq('<span data-component="docs-badges"><span data-type="tier" data-value="free"></span><span data-type="offering" data-value="self"></span></span>')
      end
    end

    context 'when <strong>(FREE EXPERIMENT)</strong> badge' do
      let(:content) { '<strong>(FREE EXPERIMENT)</strong>' }

      it 'returns correct HTML' do
        expect(run).to eq('<span data-component="docs-badges"><span data-type="tier" data-value="free"></span><span data-type="status" data-value="experiment"></span></span>')
      end
    end

    context 'when <strong>(SAAS EXPERIMENT)</strong> badge' do
      let(:content) { '<strong>(SAAS EXPERIMENT)</strong>' }

      it 'returns correct HTML' do
        expect(run).to eq('<span data-component="docs-badges"><span data-type="offering" data-value="saas"></span><span data-type="status" data-value="experiment"></span></span>')
      end
    end

    context 'when <strong>(BETA)</strong> badge' do
      let(:content) { '<strong>(BETA)</strong>' }

      it 'returns correct HTML' do
        expect(run).to eq('<span data-component="docs-badges"><span data-type="status" data-value="beta"></span></span>')
      end
    end
  end

  describe '#run_from_markdown' do
    let(:content) { nil }

    subject(:run_from_markdown) { described_class.new.run_from_markdown(content) }

    context 'when **(FREE)** badge' do
      let(:content) { '**(FREE)**' }

      it 'returns correct HTML' do
        expect(run_from_markdown).to eq('<span data-component="docs-badges"><span data-type="tier" data-value="free"></span></span>')
      end
    end

    context 'when **(FREE SELF)** badge' do
      let(:content) { '**(FREE SELF)**' }

      it 'returns correct HTML' do
        expect(run_from_markdown).to eq('<span data-component="docs-badges"><span data-type="tier" data-value="free"></span><span data-type="offering" data-value="self"></span></span>')
      end
    end

    context 'when **(FREE EXPERIMENT)** badge' do
      let(:content) { '**(FREE EXPERIMENT)**' }

      it 'returns correct HTML' do
        expect(run_from_markdown).to eq('<span data-component="docs-badges"><span data-type="tier" data-value="free"></span><span data-type="status" data-value="experiment"></span></span>')
      end
    end

    context 'when **(SAAS EXPERIMENT)** badge' do
      let(:content) { '**(SAAS EXPERIMENT)**' }

      it 'returns correct HTML' do
        expect(run_from_markdown).to eq('<span data-component="docs-badges"><span data-type="offering" data-value="saas"></span><span data-type="status" data-value="experiment"></span></span>')
      end
    end

    context 'when **(BETA)** badge' do
      let(:content) { '**(BETA)**' }

      it 'returns correct HTML' do
        expect(run_from_markdown).to eq('<span data-component="docs-badges"><span data-type="status" data-value="beta"></span></span>')
      end
    end
  end
end