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-06-10 21:09:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-10 21:09:28 +0300
commit2f7719abdfde4cb50ed05346b98bac26ea06a8de (patch)
tree71bc9a5cde931b50f38f2e2fe76cc67e1181e3d6 /spec/components/pajamas
parent37140013714814d8ffe662a372697c56eea2fde0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/components/pajamas')
-rw-r--r--spec/components/pajamas/button_component_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/components/pajamas/button_component_spec.rb b/spec/components/pajamas/button_component_spec.rb
index 0009228e58c..60c2a2e5a06 100644
--- a/spec/components/pajamas/button_component_spec.rb
+++ b/spec/components/pajamas/button_component_spec.rb
@@ -38,6 +38,14 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
expect(rendered_component).to have_css '.gl-button.btn-danger.btn-danger-tertiary.custom-class'
end
end
+
+ context 'overriding base attributes' do
+ let(:options) { { button_options: { type: 'submit' } } }
+
+ it 'overrides type' do
+ expect(rendered_component).to have_css '[type="submit"]'
+ end
+ end
end
describe 'button_text_classes' do
@@ -211,6 +219,42 @@ RSpec.describe Pajamas::ButtonComponent, type: :component do
end
end
+ describe 'type' do
+ context 'by default (without href)' do
+ it 'has type "button"' do
+ expect(rendered_component).to have_css "button[type='button']"
+ end
+ end
+
+ context 'when set to known type' do
+ where(:type) { [:button, :reset, :submit] }
+
+ let(:options) { { type: type } }
+
+ with_them do
+ it 'has the correct type' do
+ expect(rendered_component).to have_css "button[type='#{type}']"
+ end
+ end
+ end
+
+ context 'when set to unkown type' do
+ let(:options) { { type: :madeup } }
+
+ it 'has type "button"' do
+ expect(rendered_component).to have_css "button[type='button']"
+ end
+ end
+
+ context 'for links (with href)' do
+ let(:options) { { href: 'https://example.com', type: :reset } }
+
+ it 'ignores type' do
+ expect(rendered_component).not_to have_css "[type]"
+ end
+ end
+ end
+
describe 'link button' do
it 'renders a button tag with type="button" when "href" is not set' do
expect(rendered_component).to have_css "button[type='button']"