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

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

81 lines
2.2 KiB
Ruby
Raw Normal View History

2022-07-23 23:45:48 +05:30
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Pajamas::CardComponent, :aggregate_failures, type: :component do
let(:header) { 'Card header' }
let(:body) { 'Card body' }
let(:footer) { 'Card footer' }
context 'slots' do
before do
render_inline described_class.new do |c|
c.header { header }
c.body { body }
c.footer { footer }
end
end
it 'renders card header' do
2022-08-13 15:12:31 +05:30
expect(page).to have_content(header)
2022-07-23 23:45:48 +05:30
end
it 'renders card body' do
2022-08-13 15:12:31 +05:30
expect(page).to have_content(body)
2022-07-23 23:45:48 +05:30
end
it 'renders footer' do
2022-08-13 15:12:31 +05:30
expect(page).to have_content(footer)
2022-07-23 23:45:48 +05:30
end
end
context 'with defaults' do
before do
render_inline described_class.new
end
it 'does not have a header or footer' do
2022-08-13 15:12:31 +05:30
expect(page).not_to have_selector('.gl-card-header')
expect(page).not_to have_selector('.gl-card-footer')
2022-07-23 23:45:48 +05:30
end
it 'renders the card and body' do
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('.gl-card')
expect(page).to have_selector('.gl-card-body')
2022-07-23 23:45:48 +05:30
end
end
context 'with custom options' do
before do
render_inline described_class.new(
card_options: { class: '_card_class_', data: { testid: '_card_testid_' } },
header_options: { class: '_header_class_', data: { testid: '_header_testid_' } },
body_options: { class: '_body_class_', data: { testid: '_body_testid_' } },
footer_options: { class: '_footer_class_', data: { testid: '_footer_testid_' } }) do |c|
c.header { header }
c.body { body }
c.footer { footer }
end
end
it 'renders card options' do
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('._card_class_')
expect(page).to have_selector('[data-testid="_card_testid_"]')
2022-07-23 23:45:48 +05:30
end
it 'renders header options' do
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('._header_class_')
expect(page).to have_selector('[data-testid="_header_testid_"]')
2022-07-23 23:45:48 +05:30
end
it 'renders body options' do
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('._body_class_')
expect(page).to have_selector('[data-testid="_body_testid_"]')
2022-07-23 23:45:48 +05:30
end
it 'renders footer options' do
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('._footer_class_')
expect(page).to have_selector('[data-testid="_footer_testid_"]')
2022-07-23 23:45:48 +05:30
end
end
end