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

View file

@ -1,7 +1,7 @@
/* eslint-env jest */
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
import Writing from '../../src/pages/writing'
import Writing, { Title, Description } from '../../src/pages/writing'
jest.mock('next/head', () => {
return {
@ -20,26 +20,26 @@ describe('Writing', () => {
it('renders meta title', async () => {
const { container } = render(getStubWritingComponent())
expect(container.querySelector('title')).toHaveTextContent('Writing')
expect(container.querySelector('title')).toHaveTextContent(Title)
})
it('renders opengraph title', () => {
const { container } = render(getStubWritingComponent())
expect(container.querySelector('meta[property="og:title"]'))
.toHaveAttribute('content', 'Writing')
.toHaveAttribute('content', Title)
})
it('renders meta description', () => {
const { container } = render(getStubWritingComponent())
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', () => {
const { container } = render(getStubWritingComponent())
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,10 +6,10 @@ import showdown from 'showdown'
import { NextSeo } from 'next-seo'
import Resume from '@/components/Resume/Resume'
export const Title = "CV";
export const Description = "Read about my professional experience as a software engineer, core competencies, and certifications.";
export const Title = 'CV'
export const Description = 'Read about my professional experience as a software engineer, core competencies, and certifications.'
function ResumePage({
function ResumePage ({
competencies,
education,
certifications,
@ -18,12 +18,14 @@ function ResumePage({
}) {
return (
<DefaultLayout>
<NextSeo title={Title} description={Description} openGraph={
<NextSeo
title={Title} description={Description} openGraph={
{
Title,
Description
}
} />
}
/>
<section>
<h1>{Title} 💼</h1>
<p>{Description}</p>
@ -41,7 +43,7 @@ function ResumePage({
)
}
export function getStaticProps() {
export function getStaticProps () {
const content = fs.readFileSync('./content/pages/cv.yml', {
encoding: 'utf-8'
})

View file

@ -27,15 +27,15 @@ export default function Home () {
<div className='row'>
<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>
<Link href={'/writing'} className='box-link'>Read more...</Link>
<Link href='/writing' className='box-link'>Read more...</Link>
</div>
<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>
<Link href={'/writing'} className='box-link'>Read more...</Link>
<Link href='/writing' className='box-link'>Read more...</Link>
</div>
</div>
</section>

View file

@ -8,10 +8,9 @@ import { formatDate } from '@/lib/helpers'
export const getStaticProps = () => getStaticEntryListProps('./content/writing', '/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 }) {
return (
<DefaultLayout>
<NextSeo