@@ -17,19 +17,20 @@ jest.mock("@src/app/_components/nbs/NBSBookingAction", () => ({
1717
1818describe ( "EligibilityActions" , ( ) => {
1919 describe ( "when actions are present" , ( ) => {
20- describe ( "infotext " , ( ) => {
21- it ( "should display infotext content successfully" , ( ) => {
20+ describe ( "should show delineator based on last action " , ( ) => {
21+ it ( "does not show for single action" , async ( ) => {
2222 render (
2323 EligibilityActions ( {
24- actions : [ actionBuilder ( ) . withType ( ActionDisplayType . infotext ) . andContent ( "Test Content" ) . build ( ) ] ,
24+ actions : [ actionBuilder ( ) . withType ( ActionDisplayType . infotext ) . andContent ( "Test Content 1 " ) . build ( ) ] ,
2525 vaccineType : VaccineType . RSV ,
2626 } ) ,
2727 ) ;
2828
29- expectContentStringToBeVisible ( "Test Content" ) ;
29+ const content1 : HTMLElement = screen . getByText ( "Test Content 1" ) ;
30+ expect ( content1 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . not . toBe ( "HR" ) ;
3031 } ) ;
3132
32- it ( "should display multiple infotexts successfully" , ( ) => {
33+ it ( "shows below first but not the second for two actions" , async ( ) => {
3334 render (
3435 EligibilityActions ( {
3536 actions : [
@@ -40,23 +41,22 @@ describe("EligibilityActions", () => {
4041 } ) ,
4142 ) ;
4243
43- expectEachContentStringToBeVisible ( [ "Test Content 1" , "Test Content 2" ] ) ;
44+ const content1 : HTMLElement = screen . getByText ( "Test Content 1" ) ;
45+ const content2 : HTMLElement = screen . getByText ( "Test Content 2" ) ;
46+
47+ expect ( content1 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . toBe ( "HR" ) ;
48+ expect ( content2 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . not . toBe ( "HR" ) ;
4449 } ) ;
4550
46- it ( "should display delineator depending on flag" , ( ) => {
51+ it ( "shows below all but the last one for multiple mixed action types" , async ( ) => {
4752 render (
4853 EligibilityActions ( {
4954 actions : [
50- actionBuilder ( )
51- . withType ( ActionDisplayType . infotext )
52- . andContent ( "Test Content 1" )
53- . andDelineator ( true )
54- . build ( ) ,
55- actionBuilder ( )
56- . withType ( ActionDisplayType . infotext )
57- . andContent ( "Test Content 2" )
58- . andDelineator ( false )
59- . build ( ) ,
55+ actionBuilder ( ) . withType ( ActionDisplayType . infotext ) . andContent ( "Test Content 1" ) . build ( ) ,
56+ actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content 2" ) . build ( ) ,
57+ actionBuilder ( ) . withType ( ActionDisplayType . buttonWithCard ) . andContent ( "Test Content 3" ) . build ( ) ,
58+ actionBuilder ( ) . withType ( ActionDisplayType . buttonWithInfo ) . andContent ( "Test Content 4" ) . build ( ) ,
59+ actionBuilder ( ) . withType ( ActionDisplayType . actionLinkWithInfo ) . andContent ( "Test Content 5" ) . build ( ) ,
6060 ] ,
6161 vaccineType : VaccineType . RSV ,
6262 } ) ,
@@ -66,56 +66,64 @@ describe("EligibilityActions", () => {
6666 const content2 : HTMLElement = screen . getByText ( "Test Content 2" ) ;
6767
6868 expect ( content1 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . toBe ( "HR" ) ;
69- expect ( content2 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . not . toBe ( "HR" ) ;
69+ expect ( content2 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . toBe ( "HR" ) ;
70+ expectDelineatorToBePresentAfterElementWithSelector ( "Test Content 3" , ".nhsuk-card" ) ;
71+ expectDelineatorToBePresentAfterElementWithSelector ( "Test Content 4" , '[data-testid="action-paragraph"]' ) ;
72+ expectDelineatorToNotBePresentAfterElementWithSelector ( "Test Content 5" , '[data-testid="action-paragraph"]' ) ;
7073 } ) ;
7174 } ) ;
7275
73- describe ( "card " , ( ) => {
74- it ( "should display card content successfully" , ( ) => {
76+ describe ( "infotext " , ( ) => {
77+ it ( "should display infotext content successfully" , ( ) => {
7578 render (
7679 EligibilityActions ( {
77- actions : [ actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content" ) . build ( ) ] ,
80+ actions : [ actionBuilder ( ) . withType ( ActionDisplayType . infotext ) . andContent ( "Test Content" ) . build ( ) ] ,
7881 vaccineType : VaccineType . RSV ,
7982 } ) ,
8083 ) ;
8184
8285 expectContentStringToBeVisible ( "Test Content" ) ;
8386 } ) ;
8487
85- it ( "should display multiple cards successfully" , ( ) => {
88+ it ( "should display multiple infotexts successfully" , ( ) => {
8689 render (
8790 EligibilityActions ( {
8891 actions : [
89- actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content 1" ) . build ( ) ,
90- actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content 2" ) . build ( ) ,
92+ actionBuilder ( ) . withType ( ActionDisplayType . infotext ) . andContent ( "Test Content 1" ) . build ( ) ,
93+ actionBuilder ( ) . withType ( ActionDisplayType . infotext ) . andContent ( "Test Content 2" ) . build ( ) ,
9194 ] ,
9295 vaccineType : VaccineType . RSV ,
9396 } ) ,
9497 ) ;
9598
9699 expectEachContentStringToBeVisible ( [ "Test Content 1" , "Test Content 2" ] ) ;
97100 } ) ;
101+ } ) ;
98102
99- it ( "should display delineator depending on flag" , ( ) => {
103+ describe ( "card" , ( ) => {
104+ it ( "should display card content successfully" , ( ) => {
105+ render (
106+ EligibilityActions ( {
107+ actions : [ actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content" ) . build ( ) ] ,
108+ vaccineType : VaccineType . RSV ,
109+ } ) ,
110+ ) ;
111+
112+ expectContentStringToBeVisible ( "Test Content" ) ;
113+ } ) ;
114+
115+ it ( "should display multiple cards successfully" , ( ) => {
100116 render (
101117 EligibilityActions ( {
102118 actions : [
103- actionBuilder ( )
104- . withType ( ActionDisplayType . card )
105- . andContent ( "Test Content 1" )
106- . andDelineator ( false )
107- . build ( ) ,
108- actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content 2" ) . andDelineator ( true ) . build ( ) ,
119+ actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content 1" ) . build ( ) ,
120+ actionBuilder ( ) . withType ( ActionDisplayType . card ) . andContent ( "Test Content 2" ) . build ( ) ,
109121 ] ,
110122 vaccineType : VaccineType . RSV ,
111123 } ) ,
112124 ) ;
113125
114- const content1 : HTMLElement = screen . getByText ( "Test Content 1" ) ;
115- const content2 : HTMLElement = screen . getByText ( "Test Content 2" ) ;
116-
117- expect ( content1 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . not . toBe ( "HR" ) ;
118- expect ( content2 . closest ( '[data-testid="markdown-with-styling"]' ) ?. nextElementSibling ?. tagName ) . toBe ( "HR" ) ;
126+ expectEachContentStringToBeVisible ( [ "Test Content 1" , "Test Content 2" ] ) ;
119127 } ) ;
120128 } ) ;
121129
@@ -174,29 +182,6 @@ describe("EligibilityActions", () => {
174182
175183 expect ( card ) . not . toBeInTheDocument ( ) ;
176184 } ) ;
177-
178- it ( "should display delineator depending on flag" , ( ) => {
179- render (
180- EligibilityActions ( {
181- actions : [
182- actionBuilder ( )
183- . withType ( ActionDisplayType . buttonWithCard )
184- . andContent ( "Test Content 1" )
185- . andDelineator ( true )
186- . build ( ) ,
187- actionBuilder ( )
188- . withType ( ActionDisplayType . buttonWithCard )
189- . andContent ( "Test Content 2" )
190- . andDelineator ( false )
191- . build ( ) ,
192- ] ,
193- vaccineType : VaccineType . RSV ,
194- } ) ,
195- ) ;
196-
197- expectDelineatorToBePresentAfterElementWithSelector ( "Test Content 1" , ".nhsuk-card" ) ;
198- expectDelineatorToNotBePresentAfterElementWithSelector ( "Test Content 2" , ".nhsuk-card" ) ;
199- } ) ;
200185 } ) ;
201186
202187 describe ( "buttonWithInfo" , ( ) => {
@@ -254,29 +239,6 @@ describe("EligibilityActions", () => {
254239
255240 expect ( card ) . not . toBeInTheDocument ( ) ;
256241 } ) ;
257-
258- it ( "should display delineator depending on flag" , ( ) => {
259- render (
260- EligibilityActions ( {
261- actions : [
262- actionBuilder ( )
263- . withType ( ActionDisplayType . buttonWithInfo )
264- . andContent ( "Test Content 1" )
265- . andDelineator ( true )
266- . build ( ) ,
267- actionBuilder ( )
268- . withType ( ActionDisplayType . buttonWithInfo )
269- . andContent ( "Test Content 2" )
270- . andDelineator ( false )
271- . build ( ) ,
272- ] ,
273- vaccineType : VaccineType . RSV ,
274- } ) ,
275- ) ;
276-
277- expectDelineatorToBePresentAfterElementWithSelector ( "Test Content 1" , '[data-testid="action-paragraph"]' ) ;
278- expectDelineatorToNotBePresentAfterElementWithSelector ( "Test Content 2" , '[data-testid="action-paragraph"]' ) ;
279- } ) ;
280242 } ) ;
281243
282244 describe ( "actionLinkWithInfo" , ( ) => {
@@ -348,29 +310,6 @@ describe("EligibilityActions", () => {
348310
349311 expect ( card ) . not . toBeInTheDocument ( ) ;
350312 } ) ;
351-
352- it ( "should display delineator depending on flag" , ( ) => {
353- render (
354- EligibilityActions ( {
355- actions : [
356- actionBuilder ( )
357- . withType ( ActionDisplayType . actionLinkWithInfo )
358- . andContent ( "Test Content 1" )
359- . andDelineator ( true )
360- . build ( ) ,
361- actionBuilder ( )
362- . withType ( ActionDisplayType . actionLinkWithInfo )
363- . andContent ( "Test Content 2" )
364- . andDelineator ( false )
365- . build ( ) ,
366- ] ,
367- vaccineType : VaccineType . RSV ,
368- } ) ,
369- ) ;
370-
371- expectDelineatorToBePresentAfterElementWithSelector ( "Test Content 1" , '[data-testid="action-paragraph"]' ) ;
372- expectDelineatorToNotBePresentAfterElementWithSelector ( "Test Content 2" , '[data-testid="action-paragraph"]' ) ;
373- } ) ;
374313 } ) ;
375314 } ) ;
376315
0 commit comments