|
| 1 | +require_relative '../test_helper' |
| 2 | +require_relative '../helpers/fixture_flows_helper' |
| 3 | +require_relative '../fixtures/smart_answer_flows/graph' |
| 4 | + |
| 5 | +module SmartAnswer |
| 6 | + class GraphPresenterWithErbRendererTest < ActiveSupport::TestCase |
| 7 | + include FixtureFlowsHelper |
| 8 | + |
| 9 | + setup do |
| 10 | + setup_fixture_flows |
| 11 | + @flow = SmartAnswer::GraphFlow.new |
| 12 | + @flow.use_erb_templates_for_questions |
| 13 | + @flow.define |
| 14 | + @presenter = GraphPresenter.new(@flow) |
| 15 | + end |
| 16 | + |
| 17 | + teardown do |
| 18 | + teardown_fixture_flows |
| 19 | + end |
| 20 | + |
| 21 | + test "presents labels of graph flow" do |
| 22 | + expected_labels = { |
| 23 | + q1?: "MultipleChoice\n-\nWhat is the answer to q1?\n\n( ) yes\n( ) no", |
| 24 | + q2?: "MultipleChoice\n-\nWhat is the answer to q2?\n\n( ) a\n( ) b", |
| 25 | + q_with_interpolation?: "MultipleChoice\n-\nQuestion with <%= inter.pol.ation %>?\n\n( ) x\n( ) y", |
| 26 | + done_a: "Outcome\n-\ndone_a", |
| 27 | + done_b: "Outcome\n-\ndone_b" |
| 28 | + } |
| 29 | + |
| 30 | + assert_equal expected_labels, @presenter.labels |
| 31 | + end |
| 32 | + |
| 33 | + test "presents adjacency_list of simple graph" do |
| 34 | + expected_adjacency_list = { |
| 35 | + q1?: [[:q2?, ""]], |
| 36 | + q2?: [[:done_a, ''], [:q_with_interpolation?, '']], |
| 37 | + q_with_interpolation?: [[:done_b, ""]], |
| 38 | + done_a: [], |
| 39 | + done_b: [] |
| 40 | + } |
| 41 | + |
| 42 | + assert_equal expected_adjacency_list, @presenter.adjacency_list |
| 43 | + end |
| 44 | + |
| 45 | + test "indicates does not define transitions in a way which can be visualised" do |
| 46 | + p = GraphPresenter.new(SmartAnswer::GraphFlow.build) |
| 47 | + assert p.visualisable?, "'graph' should be visualisable" |
| 48 | + end |
| 49 | + end |
| 50 | +end |
0 commit comments