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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 15:10:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 15:10:44 +0300
commita4068557f4e8f0622798ccf824ac314e2008a57b (patch)
treea3ddbb6c902828009c0e02813339abe88cae9d60 /spec/components/pajamas
parentd0a683e342c9e59bec8bb83879f0fc959b79224e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/components/pajamas')
-rw-r--r--spec/components/pajamas/button_component_spec.rb54
1 files changed, 33 insertions, 21 deletions
diff --git a/spec/components/pajamas/button_component_spec.rb b/spec/components/pajamas/button_component_spec.rb
index a8c96042580..00423fd22a4 100644
--- a/spec/components/pajamas/button_component_spec.rb
+++ b/spec/components/pajamas/button_component_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
let(:content) { "Button content" }
let(:options) { {} }
- describe 'basic usage' do
+ RSpec.shared_examples 'basic button behavior' do
before do
render_inline(subject) do |c|
content
@@ -59,7 +59,7 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
describe 'disabled' do
context 'by default (false)' do
it 'does not have disabled styling and behavior' do
- expect(page).not_to have_css ".disabled[disabled='disabled'][aria-disabled='true']"
+ expect(page).not_to have_css ".disabled[disabled][aria-disabled]"
end
end
@@ -67,7 +67,7 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
let(:options) { { disabled: true } }
it 'has disabled styling and behavior' do
- expect(page).to have_css ".disabled[disabled='disabled'][aria-disabled='true']"
+ expect(page).to have_css ".disabled[disabled][aria-disabled]"
end
end
end
@@ -75,7 +75,7 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
describe 'loading' do
context 'by default (false)' do
it 'is not disabled' do
- expect(page).not_to have_css ".disabled[disabled='disabled']"
+ expect(page).not_to have_css ".disabled[disabled]"
end
it 'does not render a spinner' do
@@ -87,7 +87,7 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
let(:options) { { loading: true } }
it 'is disabled' do
- expect(page).to have_css ".disabled[disabled='disabled']"
+ expect(page).to have_css ".disabled[disabled]"
end
it 'renders a spinner' do
@@ -218,9 +218,13 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
end
end
end
+ end
+
+ context 'button component renders a button' do
+ include_examples 'basic button behavior'
describe 'type' do
- context 'by default (without href)' do
+ context 'by default' do
it 'has type "button"' do
expect(page).to have_css "button[type='button']"
end
@@ -238,34 +242,42 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
end
end
- context 'when set to unkown type' do
+ context 'when set to unknown type' do
let(:options) { { type: :madeup } }
it 'has type "button"' do
expect(page).to have_css "button[type='button']"
end
end
+ end
+ end
- context 'for links (with href)' do
- let(:options) { { href: 'https://example.com', type: :reset } }
+ context 'button component renders a link' do
+ let(:options) { { href: 'https://gitlab.com', target: '_blank' } }
- it 'ignores type' do
- expect(page).not_to have_css "[type]"
- end
- end
+ it "renders a link instead of the button" do
+ expect(page).not_to have_css "button[type='button']"
+ expect(page).to have_css "a[href='https://gitlab.com'][target='_blank']"
end
- describe 'link button' do
- it 'renders a button tag with type="button" when "href" is not set' do
- expect(page).to have_css "button[type='button']"
+ include_examples 'basic button behavior'
+
+ describe 'type' do
+ let(:options) { { href: 'https://example.com', type: :reset } }
+
+ it 'ignores type' do
+ expect(page).not_to have_css "[type]"
end
+ end
+
+ describe 'method' do
+ where(:method) { [:get, :post, :put, :delete, :patch] }
- context 'when "href" is provided' do
- let(:options) { { href: 'https://gitlab.com', target: '_blank' } }
+ let(:options) { { href: 'https://gitlab.com', method: method } }
- it "renders a link instead of the button" do
- expect(page).not_to have_css "button[type='button']"
- expect(page).to have_css "a[href='https://gitlab.com'][target='_blank']"
+ with_them do
+ it 'has the correct data-method attribute' do
+ expect(page).to have_css "a[data-method='#{method}']"
end
end
end