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()
+ expect(screen.getByTestId('footer')).toBeInTheDocument()
+ })
+})
diff --git a/src/templates/common/googleMapsDirections/index.test.tsx b/src/templates/common/googleMapsDirections/index.test.tsx
new file mode 100644
index 000000000..ac5a5f4f9
--- /dev/null
+++ b/src/templates/common/googleMapsDirections/index.test.tsx
@@ -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()
+
+ const anchorElement = screen.getByRole('link', {
+ name: /get directions on google maps/i,
+ })
+ expect(anchorElement).toBeInTheDocument()
+ expect(anchorElement).toHaveAttribute('href', expectedUrl)
+ })
+})
diff --git a/src/templates/common/header/index.test.tsx b/src/templates/common/header/index.test.tsx
new file mode 100644
index 000000000..82f6d2724
--- /dev/null
+++ b/src/templates/common/header/index.test.tsx
@@ -0,0 +1,12 @@
+import { render } from '@testing-library/react'
+import { Header } from './'
+
+describe('Header Component', () => {
+ test('renders TopNav component within the Header', () => {
+ render()
+ const headerComponent = document.querySelector('#header-v2')
+ const topnavComponent = document.querySelector('#legacy-header')
+ expect(headerComponent).toBeInTheDocument()
+ expect(topnavComponent).toBeInTheDocument()
+ })
+})
diff --git a/src/templates/common/heading/index.test.tsx b/src/templates/common/heading/index.test.tsx
new file mode 100644
index 000000000..8526cf48c
--- /dev/null
+++ b/src/templates/common/heading/index.test.tsx
@@ -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(
+
+ My Heading
+
+ )
+ const headingElement = container.querySelector('h2')
+ expect(headingElement).toBeInTheDocument()
+ expect(headingElement).toHaveAttribute('slot', 'my-slot')
+ expect(headingElement.innerHTML).toBe('My Heading')
+ })
+})
diff --git a/src/templates/common/link/index.test.tsx b/src/templates/common/link/index.test.tsx
new file mode 100644
index 000000000..598add379
--- /dev/null
+++ b/src/templates/common/link/index.test.tsx
@@ -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 Text
+
+ )
+
+ const linkElement = getByText('Link Text')
+ expect(linkElement).toBeInTheDocument()
+ expect(linkElement.tagName).toBe('SPAN')
+ })
+})
diff --git a/src/templates/common/medallia/index.test.tsx b/src/templates/common/medallia/index.test.tsx
new file mode 100644
index 000000000..875def949
--- /dev/null
+++ b/src/templates/common/medallia/index.test.tsx
@@ -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 }) => (
+
+))
+
+// 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()
+
+ 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)
+ })
+})
diff --git a/src/templates/common/util/HTMLComment.test.tsx b/src/templates/common/util/HTMLComment.test.tsx
new file mode 100644
index 000000000..6da882086
--- /dev/null
+++ b/src/templates/common/util/HTMLComment.test.tsx
@@ -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()
+
+ 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()
+
+ const commentElement = document.body.lastChild as Comment
+
+ expect(commentElement.nodeType).toBe(Node.COMMENT_NODE)
+ expect(commentElement.nodeValue).toBe(content)
+ })
+})