blob: 38d23cfca9c130558fa182032f2425906ac2c087 (
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
|
# 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
expect(page).to have_content(header)
end
it 'renders card body' do
expect(page).to have_content(body)
end
it 'renders footer' do
expect(page).to have_content(footer)
end
end
context 'with defaults' do
before do
render_inline described_class.new
end
it 'does not have a header or footer' do
expect(page).not_to have_selector('.gl-card-header')
expect(page).not_to have_selector('.gl-card-footer')
end
it 'renders the card and body' do
expect(page).to have_selector('.gl-card')
expect(page).to have_selector('.gl-card-body')
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
expect(page).to have_selector('._card_class_')
expect(page).to have_selector('[data-testid="_card_testid_"]')
end
it 'renders header options' do
expect(page).to have_selector('._header_class_')
expect(page).to have_selector('[data-testid="_header_testid_"]')
end
it 'renders body options' do
expect(page).to have_selector('._body_class_')
expect(page).to have_selector('[data-testid="_body_testid_"]')
end
it 'renders footer options' do
expect(page).to have_selector('._footer_class_')
expect(page).to have_selector('[data-testid="_footer_testid_"]')
end
end
end
|