diff --git a/src/data/queries/tests/__snapshots__/banners.test.tsx.snap b/src/data/queries/tests/__snapshots__/banners.test.tsx.snap index 4a0236464..b6170b462 100644 --- a/src/data/queries/tests/__snapshots__/banners.test.tsx.snap +++ b/src/data/queries/tests/__snapshots__/banners.test.tsx.snap @@ -19,6 +19,15 @@ exports[`Banners return formatted data outputs formatted data 1`] = ` }, { "alertType": "warning", + "bannerAlertVamcs": [ + { + "id": 2363, + "office": { + "path": null, + }, + "path": "/butler-health-care/operating-status", + }, + ], "body": "

this is a full width banner alert

", "dismiss": true, "emailUpdatesButton": true, diff --git a/src/data/queries/tests/__snapshots__/eventTeaser.test.tsx.snap b/src/data/queries/tests/__snapshots__/eventTeaser.test.tsx.snap index 0220101b7..6d0eb88a3 100644 --- a/src/data/queries/tests/__snapshots__/eventTeaser.test.tsx.snap +++ b/src/data/queries/tests/__snapshots__/eventTeaser.test.tsx.snap @@ -1,89 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`alert non reusable formatData outputs formatted data 1`] = ` -{ - "changed": "2023-08-16T15:20:30+00:00", - "entityBundle": "node--event", - "entityId": "16349f16-be65-46e3-9660-1d3d598a4a0b", - "entityPublished": true, - "entityUrl": { - "path": "/central-iowa-health-care/events/52265", - }, - "fieldAdditionalInformationAbo": null, - "fieldAdditionalListings": null, - "fieldAddress": { - "addressLine1": "9000 Douglas Ave", - "addressLine2": null, - "administrativeArea": "IA", - "countryCode": "US", - "locality": "Urbandale", - "postalCode": null, - }, - "fieldAdministration": { - "entity": { - "entityId": "3a530a55-e922-48de-b18c-9c9f92a9ae98", - }, - }, - "fieldBody": { - "format": "rich_text", - "processed": "

Pickleball Club

- -

Meets Thursdays from 9 to 11 a.m. 

- -

Contact Kay Queck (515) 214-4578

", - "value": "

Pickleball Club

- -

Meets Thursdays from 9 to 11 a.m. 

- -

Contact Kay Queck (515) 214-4578

-", - }, - "fieldCtaEmail": "test@va.gov", - "fieldDatetimeRangeTimezone": [ - { - "duration": 120, - "endTime": "2023-09-07T16:00:00+00:00", - "endValue": 1694102400, - "end_value": "2023-09-07T16:00:00+00:00", - "rrule": 180, - "rrule_index": 1, - "startTime": "2023-09-07T14:00:00+00:00", - "timezone": "America/Chicago", - "value": 1694095200, - }, - { - "duration": 120, - "endTime": "2023-09-14T16:00:00+00:00", - "endValue": 1694707200, - "end_value": "2023-09-14T16:00:00+00:00", - "rrule": 180, - "rrule_index": 2, - "startTime": "2023-09-14T14:00:00+00:00", - "timezone": "America/Chicago", - "value": 1694700000, - }, - ], - "fieldDescription": "Pickleball ", - "fieldEventCost": "Free", - "fieldEventCta": null, - "fieldEventRegistrationrequired": false, - "fieldFacilityLocation": null, - "fieldFeatured": false, - "fieldHowToSignUp": "email", - "fieldLink": null, - "fieldListing": { - "entity": { - "entityId": "55cb823c-df6d-4f77-814d-6024e08cd4f6", - }, - }, - "fieldLocationHumanreadable": "Walker Johnston Park", - "fieldLocationType": "non_facility", - "fieldOrder": null, - "fieldUrlOfAnOnlineEvent": null, - "title": "Pickleball Club", -} -`; - exports[`event teaser formatData outputs formatted data 1`] = ` { "changed": "2023-08-16T15:20:30+00:00", diff --git a/src/data/queries/tests/__snapshots__/healthServices.test.tsx.snap b/src/data/queries/tests/__snapshots__/healthServices.test.tsx.snap index c60f835b0..cc5b2696c 100644 --- a/src/data/queries/tests/__snapshots__/healthServices.test.tsx.snap +++ b/src/data/queries/tests/__snapshots__/healthServices.test.tsx.snap @@ -1,22 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`alert single formatData outputs formatted data 1`] = ` -[ - { - "alsoKnownAs": null, - "body": "

Military sexual trauma can happen to both men and women. If you experienced sexual assault or harassment during military service - no matter when you served – we provide counseling and treatment.

-", - "commonlyTreatedCondition": null, - "description": "Military sexual trauma can happen to both genders. If you experienced sexual assault or harassment during military service—no matter when you served—we provide counseling and treatment.", - "name": "Military sexual trauma care", - "vetCenterComConditions": null, - "vetCenterFriendlyName": null, - "vetCenterServiceDescription": "If you experienced sexual assault or harassment during military service, we can help you get the counseling you need. Any Veteran or service member, including members of the National Guard and Reserve forces, who experienced military sexual trauma is eligible to receive counseling. This applies to people of all genders from any service era.", - "vetCenterTypeOfCare": "counseling", - }, -] -`; - exports[`healthServices formatData outputs formatted data 1`] = ` [ { diff --git a/src/templates/common/commonAndPopular/index.test.tsx b/src/templates/common/commonAndPopular/index.test.tsx new file mode 100644 index 000000000..64956a11e --- /dev/null +++ b/src/templates/common/commonAndPopular/index.test.tsx @@ -0,0 +1,26 @@ +import { render, screen } from '@testing-library/react' +import { CommonAndPopular } from './' + +describe('CommonAndPopular Component', () => { + test('renders common and popular links correctly', () => { + render() + + const commonQuestionsLinks = screen.getAllByRole('link', { + name: /how do i /i, + }) + expect(commonQuestionsLinks).toHaveLength(3) + expect(commonQuestionsLinks[0]).toHaveAttribute( + 'href', + expect.stringMatching(/\/health-care\/how-to-apply\/?/) + ) + + const popularLinks = screen.getAllByRole('link', { + name: /view|find nearby va locations|contact the veterans crisis line/i, + }) + expect(popularLinks).toHaveLength(3) + expect(popularLinks[0]).toHaveAttribute( + 'href', + expect.stringMatching(/\/find-locations\/?/) + ) + }) +}) diff --git a/src/templates/common/contentFooter/index.test.tsx b/src/templates/common/contentFooter/index.test.tsx new file mode 100644 index 000000000..b4ff479ee --- /dev/null +++ b/src/templates/common/contentFooter/index.test.tsx @@ -0,0 +1,49 @@ +import { render, screen, fireEvent } from '@testing-library/react' +import { ContentFooter } from './' + +// Mocked dependencies +jest.mock('@/templates/common/medallia', () => ({ + MedalliaAssets: jest.fn().mockReturnValue(null), +})) +jest.mock('@/lib/utils/medallia', () => ({ + getSurveyNumber: jest.fn((pathname, isProduction) => { + return isProduction ? 'mockedSurveyNumber' : null + }), + showForm: jest.fn(), +})) +jest.mock('@/lib/utils/date', () => ({ + parseDate: jest.fn().mockReturnValue(new Date('2022-03-28')), + getDateParts: jest.fn().mockReturnValue({ + month: { name: 'March', numeric: 3, twoDigit: '03' }, + day: { numeric: 28, twoDigit: '28' }, + year: { numeric: 2022 }, + }), +})) + +describe('ContentFooter Component', () => { + test('renders last updated date correctly', () => { + const lastUpdated = '2022-03-28' + render() + + expect(screen.getByText('Last updated:')).toBeInTheDocument() + expect(screen.getByText('March 28, 2022')).toBeInTheDocument() + expect(screen.getByText('March 28, 2022')).toHaveAttribute( + 'dateTime', + '2022-03-28' + ) + }) + + test('renders feedback button correctly', () => { + render() + + expect( + screen.getByRole('button', { name: /feedback/i }) + ).toBeInTheDocument() + + fireEvent.click(screen.getByRole('button', { name: /feedback/i })) + expect( + require('@/lib/utils/medallia').getSurveyNumber + ).toHaveBeenCalledTimes(1) + expect(require('@/lib/utils/medallia').showForm).toHaveBeenCalledTimes(1) + }) +}) diff --git a/src/templates/common/footer/index.test.tsx b/src/templates/common/footer/index.test.tsx new file mode 100644 index 000000000..469f5756d --- /dev/null +++ b/src/templates/common/footer/index.test.tsx @@ -0,0 +1,9 @@ +import { render, screen } from '@testing-library/react' +import { Footer } from './' + +describe('Footer Component', () => { + test('renders without errors', () => { + render(