Skip to content

Commit

Permalink
Add specs for the brand overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
peteryates committed Aug 23, 2024
1 parent 5875fd0 commit fb7e406
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

context 'slot arguments' do
let(:slot) { :section }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides' do
let(:component_class_name) { "GovukComponent::CookieBannerComponent" }
end

context "when there is no text or block" do
specify "raises an appropriate error" do
Expand Down
1 change: 1 addition & 0 deletions spec/components/govuk_component/details_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

context 'when text is supplied' do
before { render_inline(described_class.new(**kwargs)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,5 @@
end

it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end
1 change: 1 addition & 0 deletions spec/components/govuk_component/footer_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

describe "navigation" do
let(:custom_text) { "Some meta html" }
Expand Down
1 change: 1 addition & 0 deletions spec/components/govuk_component/header_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

context 'slot arguments' do
let(:slot) { :navigation_item }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

context 'when text is supplied' do
before { render_inline(described_class.new(**kwargs)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
let(:kwargs) { { title_text: title, text: "something", title_id: 'custom-id' } }

it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end

context "when supplied with a block" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

specify "renders some page items" do
expect(rendered_content).to have_tag("nav", with: { class: component_css_class }) do
Expand Down
1 change: 1 addition & 0 deletions spec/components/govuk_component/panel_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

specify 'contains a panel with the correct title and text' do
render_inline(described_class.new(**kwargs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides' do
let(:extra_overrides) { ["GovukComponent::TagComponent"] }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
it_behaves_like "a component that accepts custom classes"
it_behaves_like "a component that accepts custom HTML attributes"
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

context "when visible is true" do
it "renders the section break with the visible class" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

subject! do
render_inline(described_class.new(**kwargs)) do |component|
Expand Down
1 change: 1 addition & 0 deletions spec/components/govuk_component/tab_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

context 'slot arguments' do
let(:slot) { :tab }
Expand Down
1 change: 1 addition & 0 deletions spec/components/govuk_component/table_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'

describe "column groups and columns" do
subject! do
Expand Down
3 changes: 3 additions & 0 deletions spec/components/govuk_component/tag_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides' do
let(:component_class) { "GovukComponent::TagComponent" }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,5 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts custom HTML attributes'
it_behaves_like 'a component that supports custom branding'
it_behaves_like 'a component that supports brand overrides'
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@

before do
class_name = defined?(component_class_name) ? component_class_name : described_class.name
extra_classes = if defined?(extra_overrides)
extra_overrides.index_with(custom_brand)
else
{}
end
extra_classes = defined?(extra_overrides) ? extra_overrides.index_with(custom_brand) : {}

Govuk::Components.configure do |conf|
conf.brand_overrides = { class_name => custom_brand, **extra_classes }
Expand Down

0 comments on commit fb7e406

Please sign in to comment.