@@ -20,18 +20,18 @@ import payapi.corcommon.model.{AmountInPence, FutureDatedPayment}
20
20
import play .api .mvc .{AnyContent , Call }
21
21
import play .api .test .FakeRequest
22
22
import uk .gov .hmrc .cardpaymentfrontend .actions .JourneyRequest
23
- import uk .gov .hmrc .cardpaymentfrontend .models .CheckYourAnswersRow
23
+ import uk .gov .hmrc .cardpaymentfrontend .models .{ CheckYourAnswersRow , Link }
24
24
import uk .gov .hmrc .cardpaymentfrontend .testsupport .ItSpec
25
25
import uk .gov .hmrc .cardpaymentfrontend .testsupport .TestOps .FakeRequestOps
26
26
import uk .gov .hmrc .cardpaymentfrontend .testsupport .stubs .PayApiStub
27
27
import uk .gov .hmrc .cardpaymentfrontend .testsupport .testdata .TestJourneys
28
- import uk .gov .hmrc .cardpaymentfrontend .models .Link
29
28
30
29
import java .time .LocalDate
31
30
32
31
class ExtendedOriginSpec extends ItSpec {
33
32
private val systemUnderTest = ExtendedBtaSa // ExtendedBtaSa is a concrete reification of the trait ExtendedOrigin, we use it as a substitute here.
34
33
private val fakeGetRequest = FakeRequest (" GET" , " /cya0" ).withSessionId()
34
+
35
35
private val testJourney = TestJourneys .BtaSa .journeyBeforeBeginWebPayment
36
36
private val testJourneyNoDueDate = TestJourneys .BtaSa .journeyBeforeBeginWebPayment.copy(journeySpecificData = testJourney.journeySpecificData.copy(dueDate = None ))
37
37
private val testJourneyOverdue = TestJourneys .BtaSa .journeyBeforeBeginWebPayment.copy(journeySpecificData = testJourneyNoDueDate.journeySpecificData.copy(dueDate = Some (LocalDate .of(2023 , 12 , 12 ))))
@@ -81,4 +81,30 @@ class ExtendedOriginSpec extends ItSpec {
81
81
result shouldBe (None )
82
82
}
83
83
}
84
+
85
+ " checkYourAnswersEmailAddressRow" - {
86
+
87
+ val jsonSessionWithEmail =
88
+ """
89
+ |{
90
+ | "email" : "email@gmail.com"
91
+ |}
92
+ |""" .stripMargin
93
+
94
+ val sessionMapWithEmail = (" TestJourneyId-44f9-ad7f-01e1d3d8f151" , jsonSessionWithEmail)
95
+ val fakeGetRequestWithEmail = FakeRequest (" GET" , " /cya0" ).withSession(sessionMapWithEmail)
96
+
97
+ " return Some[CheckYourAnswersRow] when showEmailAddress returns true" in {
98
+ val fakeJourneyRequest : JourneyRequest [AnyContent ] = new JourneyRequest (testJourney, fakeGetRequestWithEmail)
99
+ val result : Option [CheckYourAnswersRow ] = systemUnderTest.checkYourAnswersEmailAddressRow(fakeJourneyRequest)
100
+ result shouldBe Some (CheckYourAnswersRow (" check-your-details.email-address" , List (" email@gmail.com" ), Some (Link (Call (" GET" , " /pay-by-card/email-address" ), " check-your-details-email-address-change-link" , " check-your-details.change" , None ))))
101
+
102
+ }
103
+ " return None when showEmailAddress returns false" in {
104
+ val testJourneyEmailAddress = TestJourneys .BtaSa .journeyAfterBeginWebPayment
105
+ val fakeJourneyRequest : JourneyRequest [AnyContent ] = new JourneyRequest (testJourneyEmailAddress, fakeGetRequest)
106
+ val result : Option [CheckYourAnswersRow ] = systemUnderTest.checkYourAnswersEmailAddressRow(fakeJourneyRequest)
107
+ result shouldBe (None )
108
+ }
109
+ }
84
110
}
0 commit comments