debian-mirror-gitlab/spec/components/pajamas/spinner_component_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
1.6 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# 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