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

horizontal_section_component_spec.rb « layouts « components « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: efc4821391182b0af391815ab3e58e876da2bb9a (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
# frozen_string_literal: true
require "spec_helper"

RSpec.describe Layouts::HorizontalSectionComponent, type: :component do
  let(:title) { 'Naming, visibility' }
  let(:description) { 'Update your group name, description, avatar, and visibility.' }
  let(:body) { 'This is where the settings go' }

  describe 'slots' do
    it 'renders title' do
      render_inline described_class.new do |c|
        c.title { title }
        c.body { body }
      end

      expect(page).to have_css('h4', text: title)
    end

    it 'renders body slot' do
      render_inline described_class.new do |c|
        c.title { title }
        c.body { body }
      end

      expect(page).to have_content(body)
    end

    context 'when description slot is provided' do
      before do
        render_inline described_class.new do |c|
          c.title { title }
          c.description { description }
          c.body { body }
        end
      end

      it 'renders description' do
        expect(page).to have_css('p', text: description)
      end
    end

    context 'when description slot is not provided' do
      before do
        render_inline described_class.new do |c|
          c.title { title }
          c.body { body }
        end
      end

      it 'does not render description' do
        expect(page).not_to have_css('p', text: description)
      end
    end
  end

  describe 'arguments' do
    describe 'border' do
      it 'defaults to true and adds gl-border-b CSS class' do
        render_inline described_class.new do |c|
          c.title { title }
          c.body { body }
        end

        expect(page).to have_css('.gl-border-b')
      end

      it 'does not add gl-border-b CSS class when set to false' do
        render_inline described_class.new(border: false) do |c|
          c.title { title }
          c.body { body }
        end

        expect(page).not_to have_css('.gl-border-b')
      end
    end

    describe 'options' do
      it 'adds options to wrapping element' do
        render_inline described_class.new(options: { data: { testid: 'foo-bar' }, class: 'foo-bar' }) do |c|
          c.title { title }
          c.body { body }
        end

        expect(page).to have_css('.foo-bar[data-testid="foo-bar"]')
      end
    end
  end
end