require "test_helper"
require "support/flow_test_helper"

class MaternityPaternityCalculatorFlowTest < ActiveSupport::TestCase
  include FlowTestHelper

  setup { testing_flow MaternityPaternityCalculatorFlow }

  should "render a start page" do
    assert_rendered_start_page
  end

  context "question: what_type_of_leave?" do
    setup { testing_node :what_type_of_leave? }

    should "render the question" do
      assert_rendered_question
    end

    context "next_node" do
      should "have a next node of baby_due_date_maternity? for a 'maternity' response" do
        assert_next_node :baby_due_date_maternity?, for_response: "maternity"
      end

      should "have a next node of leave_or_pay_for_adoption? for a 'paternity' response" do
        assert_next_node :leave_or_pay_for_adoption?, for_response: "paternity"
      end

      should "have a next node of taking_paternity_or_maternity_leave_for_adoption? for a 'adoption' response" do
        assert_next_node :taking_paternity_or_maternity_leave_for_adoption?, for_response: "adoption"
      end
    end
  end
end

Test core class of MaternityPaternityCalculatorFlow
Test core class of MaternityPaternityCalculatorFlow

This commit is the first in a series of commits to apply the ADR-3 [1]
style of flow tests to the MaternityPaternityCalculatorFlow.

This commit in particular adds tests to the one node that is defined in
MaternityPaternityCalculatorFlow. I've decided to break up the testing
of this flow into tests that match the individual files
(MaternityPaternityCalculatorFlow::AdoptionCalculatorFlow etc) that are
used to define it. I've done this as a way to try cope with the length
and complexity of the flows - as I found my initial pass, of putting
all the flow tests into a single file, created a file that was
overwhelming in length (> 2000 lines). The split isn't the easiest to
follow as all files are coupled and intertwined.

[1]: https://github.com/alphagov/smart-answers/blob/main/docs/arch/003-testing-flows.md
