Skip to content

Commit

Permalink
Add view tests for secondary_skip#edit
Browse files Browse the repository at this point in the history
Add simple view tests for editing the secondary skip.
  • Loading branch information
thomasiles committed Dec 12, 2024
1 parent 3b94350 commit 9795c73
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions spec/views/pages/secondary_skip/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require "rails_helper"

describe "pages/secondary_skip/edit.html.erb" do
let(:form) { build :form, id: 1, pages: [page] }
let(:page) do
build(:page,
:with_selections_settings,
id: 1,
position: 1,
answer_settings: DataStruct.new(
only_one_option: true,
selection_options: [
OpenStruct.new(attributes: { name: "Option 1" }),
OpenStruct.new(attributes: { name: "Option 2" }),
],
),
routing_conditions: [
build(:condition, id: 1, routing_page_id: 1, check_page_id: 1, answer_value: "Yes", goto_page_id: 2, skip_to_end: false),
])
end

let(:secondary_skip_input) { Pages::SecondarySkipInput.new(form:, page:) }

before do
assign(:secondary_skip_input, secondary_skip_input)
render template: "pages/secondary_skip/edit"
end

it "has the correct title" do
expect(view.content_for(:title)).to have_content(I18n.t("page_titles.new_secondary_skip", route_index: 2))
end

it "has the correct back link" do
expect(view.content_for(:back_link)).to have_link(I18n.t("secondary_skip.new.back", page_position: 1), href: show_routes_path(form_id: 1, page_id: 1))
end

it "has the correct heading and caption" do
expect(rendered).to have_selector("h1", text: "Question 1’s routes")
expect(rendered).to have_selector("h1", text: I18n.t("page_titles.new_secondary_skip", route_index: 2))
end
end

0 comments on commit 9795c73

Please sign in to comment.