# frozen_string_literal: true

Given("there exists a tracking link with destination {string}") do |destination|
  @context.setup_tracking_link(destination: destination)
end

When("I go to view tracking links") do
  @context.view_all_tracking_links
end

Then("I see a list of all tracking links") do
  @context.expect_all_tracking_links_visible
end

Given("I create a tracking link with destination {string}") do |destination|
  @context.create_tracking_link(destination: destination)
end

Then("I should see a tracking link with the destination {string}") do |destination|
  @context.expect_tracking_link_by_destination(destination)
end

Given("there is a {string} tracking link with the destination {string}") do |status, destination|
  @context.setup_tracking_link(destination: destination, status: status)
  @context.view_last_tracking_link
end

When("I edit the tracking link with the following information:") do |table|
  @context.fill_in_form(table.rows)
end

Then("when I look at the tracking link with the destination {string} I see the following information set:") do |destination, table|
  @context.expect_fields_to_match(destination, table.rows)
end

Then("there are now {int} tracking link records with the destination {string} and the same slug") do |number, destination|
  @context.expect_number_of_existing_tracking_links(amount: number, destination: destination)
end
