Skip to content

Commit

Permalink
Mock time in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rudigiesler committed Jan 13, 2025
1 parent 3dd6226 commit 969e0f0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Onboarding/QA/tests/profile-pregnancy-health_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -815,12 +815,14 @@ defmodule ProfilePregnancyHealthTest do
end

test "edd day then not number error", %{flow: flow} do
months = get_months()
fake_time = ~U[2023-02-28 00:00:00Z]
months = get_months(fake_time)
month_words = get_month_words(months)
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
month = elem(Enum.at(list_of_months, 1), 0)

flow
|> FlowTester.set_fake_time(~U[2023-02-28 00:00:00Z])
|> go_to_edd_day(month)
|> FlowTester.send("falalalalaaaaa")
|> receive_message(%{
Expand All @@ -829,12 +831,14 @@ defmodule ProfilePregnancyHealthTest do
end

test "edd day then not a day error", %{flow: flow} do
months = get_months()
fake_time = ~U[2023-02-28 00:00:00Z]
months = get_months(fake_time)
month_words = get_month_words(months)
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
month = elem(Enum.at(list_of_months, 1), 0)

flow
|> FlowTester.set_fake_time(fake_time)
|> go_to_edd_day(month)
|> FlowTester.send("0")
|> receive_message(%{
Expand All @@ -843,12 +847,14 @@ defmodule ProfilePregnancyHealthTest do
end

test "edd day then above max day error", %{flow: flow} do
months = get_months()
fake_time = ~U[2023-02-28 00:00:00Z]
months = get_months(fake_time)
month_words = get_month_words(months)
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
month = elem(Enum.at(list_of_months, 1), 0)

flow
|> FlowTester.set_fake_time(fake_time)
|> go_to_edd_day(month)
|> FlowTester.send("32")
|> receive_message(%{
Expand Down Expand Up @@ -2672,12 +2678,14 @@ defmodule ProfilePregnancyHealthTest do
end

test "edd day then not number error", %{flow: flow} do
months = get_months()
fake_time = ~U[2023-02-28 00:00:00Z]
months = get_months(fake_time)
month_words = get_month_words(months)
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
month = elem(Enum.at(list_of_months, 1), 0)

flow
|> FlowTester.set_fake_time(~U[2023-02-28 00:00:00Z])
|> go_to_edd_day(month, "Partner is pregnant")
|> FlowTester.send("falalalalaaaaa")
|> receive_message(%{
Expand All @@ -2686,12 +2694,14 @@ defmodule ProfilePregnancyHealthTest do
end

test "edd day then not a day error", %{flow: flow} do
months = get_months()
fake_time = ~U[2023-02-28 00:00:00Z]
months = get_months(fake_time)
month_words = get_month_words(months)
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
month = elem(Enum.at(list_of_months, 1), 0)

flow
|> FlowTester.set_fake_time(fake_time)
|> go_to_edd_day(month, "Partner is pregnant")
|> FlowTester.send("0")
|> receive_message(%{
Expand All @@ -2700,12 +2710,14 @@ defmodule ProfilePregnancyHealthTest do
end

test "edd day then above max day error", %{flow: flow} do
months = get_months()
fake_time = ~U[2023-02-28 00:00:00Z]
months = get_months(fake_time)
month_words = get_month_words(months)
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
month = elem(Enum.at(list_of_months, 1), 0)

flow
|> FlowTester.set_fake_time(fake_time)
|> go_to_edd_day(month, "Partner is pregnant")
|> FlowTester.send("32")
|> receive_message(%{
Expand Down

0 comments on commit 969e0f0

Please sign in to comment.