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

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

RSpec.describe Pajamas::SpinnerComponent, type: :component do
  let(:options) { {} }

  before do
    render_inline(described_class.new(**options))
  end

  describe 'class' do
    let(:options) { { class: 'gl-my-6' } }

    it 'has the correct custom class' do
      expect(page).to have_css '.gl-spinner-container.gl-my-6'
    end
  end

  describe 'color' do
    context 'by default' do
      it 'is dark' do
        expect(page).to have_css '.gl-spinner.gl-spinner-dark'
      end
    end

    context 'set to light' do
      let(:options) { { color: :light } }

      it 'is light' do
        expect(page).to have_css '.gl-spinner.gl-spinner-light'
      end
    end
  end

  describe 'inline' do
    context 'by default' do
      it 'renders a div' do
        expect(page).to have_css 'div.gl-spinner'
      end
    end

    context 'set to true' do
      let(:options) { { inline: true } }

      it 'renders a span' do
        expect(page).to have_css 'span.gl-spinner'
      end
    end
  end

  describe 'label' do
    context 'by default' do
      it 'has "Loading" as aria-label' do
        expect(page).to have_css '.gl-spinner[aria-label="Loading"]'
      end
    end

    context 'when set to something else' do
      let(:options) { { label: "Sending" } }

      it 'has a custom aria-label' do
        expect(page).to have_css '.gl-spinner[aria-label="Sending"]'
      end
    end
  end

  describe 'size' do
    let(:options) { { size: :lg } }

    it 'has the correct size class' do
      expect(page).to have_css '.gl-spinner.gl-spinner-lg'
    end
  end
end