-
Notifications
You must be signed in to change notification settings - Fork 7
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
2 changed files
with
71 additions
and
2 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
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,69 @@ | ||
import { cleanup, render } from '@testing-library/svelte' | ||
import { afterEach, describe, expect, it } from 'vitest' | ||
import RoleDetails from './role-details.svelte' | ||
|
||
describe('RoleDetails', () => { | ||
const defaultProps = { | ||
position: 'Software Developer', | ||
company: 'Tech Corp', | ||
startDate: new Date('2020-01-01'), | ||
endDate: new Date('2022-12-31'), | ||
} | ||
|
||
afterEach(() => { | ||
cleanup() | ||
}) | ||
|
||
it('renders the position and company', () => { | ||
const { getByText } = render(RoleDetails, { ...defaultProps }) | ||
|
||
expect(getByText('Software Developer')).not.toBeNull() | ||
expect(getByText('Tech Corp')).not.toBeNull() | ||
}) | ||
|
||
it('formats dates correctly when both start and end dates are valid', () => { | ||
const { getByText } = render(RoleDetails, { ...defaultProps }) | ||
|
||
expect( | ||
getByText('Jan 2020 - Dec 2022 (2yrs 11mos)') | ||
).not.toBeNull() | ||
}) | ||
|
||
it('shows "Present" for an invalid end date', () => { | ||
const { getByText } = render(RoleDetails, { | ||
...defaultProps, | ||
endDate: null, | ||
}) | ||
|
||
expect(getByText('Jan 2020 - Present (3yrs 7mos)')).not.toBeNull() | ||
}) | ||
|
||
it('shows duration correctly for 1 year', () => { | ||
const { getByText } = render(RoleDetails, { | ||
...defaultProps, | ||
endDate: new Date('2021-01-01'), | ||
}) | ||
|
||
expect(getByText('Jan 2020 - Jan 2021 (1yr)')).not.toBeNull() | ||
}) | ||
|
||
it('shows duration correctly for 1 month', () => { | ||
const { getByText } = render(RoleDetails, { | ||
...defaultProps, | ||
startDate: new Date('2022-01-01'), | ||
endDate: new Date('2022-02-01'), | ||
}) | ||
|
||
expect(getByText('Jan 2022 - Feb 2022 (1mo)')).not.toBeNull() | ||
}) | ||
|
||
it('shows duration correctly for a combination of years and months', () => { | ||
const { getByText } = render(RoleDetails, { | ||
...defaultProps, | ||
startDate: new Date('2020-01-01'), | ||
endDate: new Date('2021-02-01'), | ||
}) | ||
|
||
expect(getByText('Jan 2020 - Feb 2021 (1yr 1mo)')).not.toBeNull() | ||
}) | ||
}) |
0713745
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cv – ./
www.mecv.xyz
cv-git-main-spences10.vercel.app
mecv.xyz
cv-spences10.vercel.app