-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
239 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
src/data/queries/tests/__snapshots__/eventTeaser.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "<p>Pickleball Club</p> | ||
<p>Meets Thursdays from 9 to 11 a.m. </p> | ||
<p>Contact Kay Queck (515) 214-4578</p>", | ||
"value": "<p>Pickleball Club</p> | ||
<p>Meets Thursdays from 9 to 11 a.m. </p> | ||
<p>Contact Kay Queck (515) 214-4578</p> | ||
", | ||
}, | ||
"fieldCtaEmail": "[email protected]", | ||
"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", | ||
|
17 changes: 0 additions & 17 deletions
17
src/data/queries/tests/__snapshots__/healthServices.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<CommonAndPopular />) | ||
|
||
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\/?/) | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<ContentFooter lastUpdated={lastUpdated} />) | ||
|
||
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(<ContentFooter />) | ||
|
||
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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { Footer } from './' | ||
|
||
describe('Footer Component', () => { | ||
test('renders without errors', () => { | ||
render(<Footer />) | ||
expect(screen.getByTestId('footer')).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { GoogleMapsDirections } from './' | ||
|
||
describe('GoogleMapsDirections Component', () => { | ||
test('renders anchor element with correct href attribute', () => { | ||
const title = 'Target Location' | ||
const address = '123 Main St, City, Country' | ||
const expectedUrl = `https://maps.google.com?saddr=Current+Location&daddr=${encodeURIComponent( | ||
address | ||
)}` | ||
|
||
render(<GoogleMapsDirections title={title} address={address} />) | ||
|
||
const anchorElement = screen.getByRole('link', { | ||
name: /get directions on google maps/i, | ||
}) | ||
expect(anchorElement).toBeInTheDocument() | ||
expect(anchorElement).toHaveAttribute('href', expectedUrl) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { render } from '@testing-library/react' | ||
import { Header } from './' | ||
|
||
describe('Header Component', () => { | ||
test('renders TopNav component within the Header', () => { | ||
render(<Header />) | ||
const headerComponent = document.querySelector('#header-v2') | ||
const topnavComponent = document.querySelector('#legacy-header') | ||
expect(headerComponent).toBeInTheDocument() | ||
expect(topnavComponent).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { render } from '@testing-library/react' | ||
import { HeadingElement } from './' | ||
|
||
describe('HeadingElement Component', () => { | ||
test('renders heading element with correct level', () => { | ||
const { container } = render( | ||
<HeadingElement headingLevel="h2" slot="my-slot"> | ||
My Heading | ||
</HeadingElement> | ||
) | ||
const headingElement = container.querySelector('h2') | ||
expect(headingElement).toBeInTheDocument() | ||
expect(headingElement).toHaveAttribute('slot', 'my-slot') | ||
expect(headingElement.innerHTML).toBe('My Heading') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { render } from '@testing-library/react' | ||
import Link from './' | ||
|
||
// Mock useRouter hook for link component | ||
jest.mock('next/router', () => ({ | ||
useRouter: () => ({ | ||
basePath: '', | ||
pathname: '/', | ||
query: {}, | ||
asPath: '', | ||
push: jest.fn(), | ||
replace: jest.fn(), | ||
reload: jest.fn(), | ||
back: jest.fn(), | ||
prefetch: async () => undefined, | ||
beforePopState: () => undefined, | ||
events: { | ||
on: () => undefined, | ||
off: () => undefined, | ||
emit: () => undefined, | ||
}, | ||
isFallback: false, | ||
}), | ||
})) | ||
|
||
describe('Link Component', () => { | ||
test('renders link with text content correctly', () => { | ||
const { getByText } = render( | ||
<Link href="/some-link"> | ||
<span>Link Text</span> | ||
</Link> | ||
) | ||
|
||
const linkElement = getByText('Link Text') | ||
expect(linkElement).toBeInTheDocument() | ||
expect(linkElement.tagName).toBe('SPAN') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { MedalliaAssets } from './' | ||
|
||
// Mocking useEffect | ||
jest.mock('react', () => ({ | ||
...jest.requireActual('react'), | ||
useEffect: jest.fn(), | ||
})) | ||
|
||
// Mock Script | ||
jest.mock('next/script', () => ({ id, src }) => ( | ||
<div data-testid={id} data-src={src} /> | ||
)) | ||
|
||
// Mock medallia | ||
jest.mock('@/lib/utils/medallia', () => ({ | ||
getSurveyNumber: jest.fn(), | ||
loadForm: jest.fn(), | ||
onMedalliaLoaded: jest.fn((callback) => callback()), | ||
setWindowVaSurvey: jest.fn(), | ||
})) | ||
|
||
describe('MedalliaAssets Component', () => { | ||
test('renders Script component with correct props', () => { | ||
process.env.NEXT_PUBLIC_BUILD_TYPE = 'local' | ||
|
||
render(<MedalliaAssets />) | ||
|
||
const scriptElement = screen.getByTestId('medallia') as HTMLDivElement | ||
expect(scriptElement).toBeInTheDocument() | ||
|
||
const expectedSrc = | ||
'https://resource.digital.voice.va.gov/wdcvoice/5/onsite/embed.js' | ||
expect(scriptElement.getAttribute('data-src')).toEqual(expectedSrc) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { render } from '@testing-library/react' | ||
import HTMLComment from './HTMLComment' | ||
|
||
describe('HTMLComment Component', () => { | ||
test('renders comment in head position', () => { | ||
const content = 'Test comment' | ||
render(<HTMLComment position="head" content={content} />) | ||
|
||
const commentElement = document.head.firstChild as Comment | ||
|
||
expect(commentElement.nodeType).toBe(Node.COMMENT_NODE) | ||
expect(commentElement.nodeValue).toBe(content) | ||
}) | ||
|
||
test('renders comment in footer position', () => { | ||
const content = 'Test comment' | ||
render(<HTMLComment position="footer" content={content} />) | ||
|
||
const commentElement = document.body.lastChild as Comment | ||
|
||
expect(commentElement.nodeType).toBe(Node.COMMENT_NODE) | ||
expect(commentElement.nodeValue).toBe(content) | ||
}) | ||
}) |