Skip to content

Commit

Permalink
feat(TagDigest): add Bookmark component tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kechicode committed Nov 26, 2024
1 parent 2c49038 commit 917995d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/components/TagDigest/Bookmark/Bookmark.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { MockedProvider } from '@apollo/react-testing'
import { render, screen } from '@testing-library/react'
import { IntlProvider } from 'react-intl'
import { describe, expect, it } from 'vitest'

import { TEST_ID } from '~/common/enums'
import { TagDigest } from '~/components'
import { MOCK_TAG } from '~/stories/mocks'

describe('<TagDigest.Bookmark>', () => {
it('should render a TagDigest.Bookmark', () => {
render(
<MockedProvider mocks={[]} addTypename={false}>
<IntlProvider locale="en">
<TagDigest.Bookmark tag={MOCK_TAG} />
</IntlProvider>
</MockedProvider>
)

const $bookmark = screen.getByTestId(TEST_ID.DIGEST_TAG_BOOKMARK)
expect($bookmark).toBeInTheDocument()

const $name = screen.getByText(MOCK_TAG.content)
expect($name).toBeInTheDocument()

const $bookmarkButton = screen.getByRole('button', {
name: 'Bookmark',
})
expect($bookmarkButton).toBeInTheDocument()
})

it('should render a TagDigest.Bookmark with isFollower', () => {
render(
<MockedProvider mocks={[]} addTypename={false}>
<IntlProvider locale="en">
<TagDigest.Bookmark
tag={{
...MOCK_TAG,
isFollower: true,
}}
/>
</IntlProvider>
</MockedProvider>
)

const $bookmarkButton = screen.getByRole('button', {
name: 'Remove bookmark',
})
expect($bookmarkButton).toBeInTheDocument()
})
})

0 comments on commit 917995d

Please sign in to comment.