Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamplesnik committed Oct 1, 2024
1 parent 70ddc06 commit 94c8162
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 40 deletions.
9 changes: 4 additions & 5 deletions src/components/Link.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { toJson } from '@/utils/toJson'
import { Cog } from 'lucide-react'
import renderer from 'react-test-renderer'
import { expect, test } from 'vitest'
import Link from './Link'

test('Link with href', () => {
const component = renderer.create(<Link href="url/">link</Link>)
let tree = toJson(component)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})

Expand All @@ -16,16 +15,16 @@ test('Link with href and custom target', () => {
link
</Link>
)
let tree = toJson(component)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})

test('Link with href, custom target and icon', () => {
const component = renderer.create(
<Link href="url/" target="_self" Icon={Cog}>
<Link href="url/" target="_self">
link
</Link>
)
let tree = toJson(component)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})
22 changes: 4 additions & 18 deletions src/components/Paragraph.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,16 @@ import renderer from 'react-test-renderer'
import { expect, test } from 'vitest'
import Paragraph from './Paragraph'

test('Small paragraph', () => {
const component = renderer.create(<Paragraph size="small">Small paragraph</Paragraph>)
let tree = toJson(component)
expect(tree).toMatchSnapshot()
})

test('Regular paragraph', () => {
const component = renderer.create(<Paragraph size="regular">Regular paragraph</Paragraph>)
let tree = toJson(component)
expect(tree).toMatchSnapshot()
})

test('Large paragraph', () => {
const component = renderer.create(<Paragraph size="large">Large paragraph</Paragraph>)
let tree = toJson(component)
const component = renderer.create(<Paragraph>Regular paragraph</Paragraph>)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})

test('Regular paragraph with class name', () => {
const component = renderer.create(
<Paragraph size="regular" className="test-class">
Regular paragraph with class name
</Paragraph>
<Paragraph className="test-class">Paragraph with class name</Paragraph>
)
let tree = toJson(component)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})
18 changes: 1 addition & 17 deletions src/components/__snapshots__/Paragraph.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Large paragraph 1`] = `
<p
className="mb-5 w-full text-base leading-7 last:mb-0"
>
Large paragraph
</p>
`;

exports[`Regular paragraph 1`] = `
<p
className="mb-5 w-full text-base leading-7 last:mb-0"
Expand All @@ -20,14 +12,6 @@ exports[`Regular paragraph with class name 1`] = `
<p
className="mb-5 w-full text-base leading-7 last:mb-0 test-class"
>
Regular paragraph with class name
</p>
`;

exports[`Small paragraph 1`] = `
<p
className="mb-5 w-full text-base leading-7 last:mb-0"
>
Small paragraph
Paragraph with class name
</p>
`;

0 comments on commit 94c8162

Please sign in to comment.