chore: fix tests

This commit is contained in:
Aaron Yarborough 2025-01-26 21:19:11 +00:00
parent ba6389576e
commit 0a3b6f1d04
5 changed files with 20 additions and 18 deletions

View file

@ -2,6 +2,7 @@
import { render } from '@testing-library/react' import { render } from '@testing-library/react'
import Article from '../../src/components/Article/Article' import Article from '../../src/components/Article/Article'
import '@testing-library/jest-dom' import '@testing-library/jest-dom'
import { formatDate } from '@/lib/helpers'
describe('Article', () => { describe('Article', () => {
it('renders title', () => { it('renders title', () => {
@ -21,7 +22,7 @@ describe('Article', () => {
it('renders pubdate if available', () => { it('renders pubdate if available', () => {
const props = generateArticleProps() const props = generateArticleProps()
const { getByText } = render(<Article {...props} />) const { getByText } = render(<Article {...props} />)
const pubdateElement = getByText(props.attributes.pubdate) const pubdateElement = getByText(formatDate(props.attributes.pubdate))
expect(pubdateElement).toBeInTheDocument() expect(pubdateElement).toBeInTheDocument()
}) })

View file

@ -1,7 +1,7 @@
/* eslint-env jest */ /* eslint-env jest */
import { render } from '@testing-library/react' import { render } from '@testing-library/react'
import '@testing-library/jest-dom' import '@testing-library/jest-dom'
import Writing from '../../src/pages/writing' import Writing, { Title, Description } from '../../src/pages/writing'
jest.mock('next/head', () => { jest.mock('next/head', () => {
return { return {
@ -20,26 +20,26 @@ describe('Writing', () => {
it('renders meta title', async () => { it('renders meta title', async () => {
const { container } = render(getStubWritingComponent()) const { container } = render(getStubWritingComponent())
expect(container.querySelector('title')).toHaveTextContent('Writing') expect(container.querySelector('title')).toHaveTextContent(Title)
}) })
it('renders opengraph title', () => { it('renders opengraph title', () => {
const { container } = render(getStubWritingComponent()) const { container } = render(getStubWritingComponent())
expect(container.querySelector('meta[property="og:title"]')) expect(container.querySelector('meta[property="og:title"]'))
.toHaveAttribute('content', 'Writing') .toHaveAttribute('content', Title)
}) })
it('renders meta description', () => { it('renders meta description', () => {
const { container } = render(getStubWritingComponent()) const { container } = render(getStubWritingComponent())
expect(container.querySelector('meta[name="description"]')) expect(container.querySelector('meta[name="description"]'))
.toHaveAttribute('content', 'Come get ya thoughts, ramblings, technical writing and other long-from text content here!') .toHaveAttribute('content', Description)
}) })
it('renders opengraph description', () => { it('renders opengraph description', () => {
const { container } = render(getStubWritingComponent()) const { container } = render(getStubWritingComponent())
expect(container.querySelector('meta[property="og:description"]')) expect(container.querySelector('meta[property="og:description"]'))
.toHaveAttribute('content', 'Come get ya thoughts, ramblings, technical writing and other long-from text content here!') .toHaveAttribute('content', Description)
}) })
}) })

View file

@ -6,8 +6,8 @@ import showdown from 'showdown'
import { NextSeo } from 'next-seo' import { NextSeo } from 'next-seo'
import Resume from '@/components/Resume/Resume' import Resume from '@/components/Resume/Resume'
export const Title = "CV"; export const Title = 'CV'
export const Description = "Read about my professional experience as a software engineer, core competencies, and certifications."; export const Description = 'Read about my professional experience as a software engineer, core competencies, and certifications.'
function ResumePage ({ function ResumePage ({
competencies, competencies,
@ -18,12 +18,14 @@ function ResumePage({
}) { }) {
return ( return (
<DefaultLayout> <DefaultLayout>
<NextSeo title={Title} description={Description} openGraph={ <NextSeo
title={Title} description={Description} openGraph={
{ {
Title, Title,
Description Description
} }
} /> }
/>
<section> <section>
<h1>{Title} 💼</h1> <h1>{Title} 💼</h1>
<p>{Description}</p> <p>{Description}</p>

View file

@ -27,15 +27,15 @@ export default function Home () {
<div className='row'> <div className='row'>
<div className='box'> <div className='box'>
<Link href={'/writing'} className='box-title'>{WritingTitle}</Link> <Link href='/writing' className='box-title'>{WritingTitle}</Link>
<p className='box-text'>{WritingDescription}</p> <p className='box-text'>{WritingDescription}</p>
<Link href={'/writing'} className='box-link'>Read more...</Link> <Link href='/writing' className='box-link'>Read more...</Link>
</div> </div>
<div className='box'> <div className='box'>
<Link href={'/cv'} className='box-title'>{CvTitle}</Link> <Link href='/cv' className='box-title'>{CvTitle}</Link>
<p className='box-text'>{CvDescription}</p> <p className='box-text'>{CvDescription}</p>
<Link href={'/writing'} className='box-link'>Read more...</Link> <Link href='/writing' className='box-link'>Read more...</Link>
</div> </div>
</div> </div>
</section> </section>

View file

@ -8,10 +8,9 @@ import { formatDate } from '@/lib/helpers'
export const getStaticProps = () => getStaticEntryListProps('./content/writing', '/writing/') export const getStaticProps = () => getStaticEntryListProps('./content/writing', '/writing/')
export const Title = 'Writing' export const Title = 'Writing'
export const Description = 'A collection of writing and musings on various topics that interest me, as well as technical writing.'; export const Description = 'A collection of writing and musings on various topics that interest me, as well as technical writing.'
export default function Writing ({ entries, urlPrefix }) { export default function Writing ({ entries, urlPrefix }) {
return ( return (
<DefaultLayout> <DefaultLayout>
<NextSeo <NextSeo