-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
a586ef9
commit d1b23de
Showing
52 changed files
with
3,470 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import AuthorAndDescription from './AuthorAndDescription'; | ||
|
||
describe('AuthorAndDescription', () => { | ||
test('renders author and description', () => { | ||
const author = 'John Doe'; | ||
const description = 'This is a test description.'; | ||
render(<AuthorAndDescription author={author} description={description} />); | ||
|
||
const authorElement = screen.getByText(`${author}`); | ||
const descriptionElement = screen.getByText(description); | ||
|
||
expect(authorElement).toBeInTheDocument(); | ||
expect(descriptionElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('renders author with correct class', () => { | ||
const author = 'Jane Doe'; | ||
render(<AuthorAndDescription author={author} description="" />); | ||
|
||
const authorElement = screen.getByText(`${author}`); | ||
expect(authorElement).toBeInTheDocument(); | ||
expect(authorElement).toHaveClass('group-hover:text-violet-500'); | ||
}); | ||
|
||
test('renders description with correct class', () => { | ||
const description = 'Another test description.'; | ||
render(<AuthorAndDescription author="" description={description} />); | ||
|
||
const descriptionElement = screen.getByText(description); | ||
expect(descriptionElement).toBeInTheDocument(); | ||
expect(descriptionElement).toHaveClass('mr-5'); | ||
}); | ||
}); |
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,45 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import CardAnnotations from './CardAnnotations'; | ||
|
||
describe('CardAnnotations', () => { | ||
test('renders favorite annotation', () => { | ||
render(<CardAnnotations isFavorite={true} isNotADayOld={false} isTrending={false} />); | ||
const favoriteAnnotation = screen.getByText('Favorite'); | ||
expect(favoriteAnnotation).toBeInTheDocument(); | ||
expect(favoriteAnnotation).toHaveAttribute('title', 'Favorite plugin'); | ||
}); | ||
|
||
test('renders new annotation', () => { | ||
render(<CardAnnotations isFavorite={false} isNotADayOld={true} isTrending={false} category="Plugin" />); | ||
const newAnnotation = screen.getByText('New Plugin'); | ||
expect(newAnnotation).toBeInTheDocument(); | ||
expect(newAnnotation).toHaveAttribute('title', 'Less than a day old'); | ||
}); | ||
|
||
test('renders trending annotation', () => { | ||
render(<CardAnnotations isFavorite={false} isNotADayOld={false} isTrending={true} />); | ||
const trendingAnnotation = screen.getByText('Trending'); | ||
expect(trendingAnnotation).toBeInTheDocument(); | ||
expect(trendingAnnotation).toHaveAttribute('title', 'Trending plugin'); | ||
}); | ||
|
||
test('renders multiple annotations', () => { | ||
render(<CardAnnotations isFavorite={true} isNotADayOld={true} isTrending={true} category="Plugin" />); | ||
const favoriteAnnotation = screen.getByText('Favorite'); | ||
const newAnnotation = screen.getByText('New Plugin'); | ||
const trendingAnnotation = screen.getByText('Trending'); | ||
|
||
expect(favoriteAnnotation).toBeInTheDocument(); | ||
expect(newAnnotation).toBeInTheDocument(); | ||
expect(trendingAnnotation).toBeInTheDocument(); | ||
}); | ||
|
||
test('renders no annotations when all props are false', () => { | ||
render(<CardAnnotations isFavorite={false} isNotADayOld={false} isTrending={false} />); | ||
expect(screen.queryByText('Favorite')).not.toBeInTheDocument(); | ||
expect(screen.queryByText('New')).not.toBeInTheDocument(); | ||
expect(screen.queryByText('Trending')).not.toBeInTheDocument(); | ||
}); | ||
}); |
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,34 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { CategoryIcon } from './Category'; | ||
|
||
describe('CategoryIcon', () => { | ||
const categories = [ | ||
{ name: 'Task Management', testId: 'task-management-icon' }, | ||
{ name: 'File Management', testId: 'file-management-icon' }, | ||
{ name: 'Note Enhancements', testId: 'note-enhancements-icon' }, | ||
{ name: 'Data Visualization', testId: 'data-visualization-icon' }, | ||
{ name: '3rd Party Integrations', testId: 'third-party-integrations-icon' }, | ||
{ name: 'Productivity Tools', testId: 'productivity-tools-icon' }, | ||
{ name: 'Coding & Technical Tools', testId: 'coding-technical-tools-icon' }, | ||
{ name: 'Creative & Writing Tools', testId: 'creative-writing-tools-icon' }, | ||
{ name: 'Privacy & Security', testId: 'privacy-security-icon' }, | ||
{ name: 'Customization & UI', testId: 'customization-ui-icon' }, | ||
{ name: 'Collaboration & Sharing', testId: 'collaboration-sharing-icon' }, | ||
{ name: 'Learning & Knowledge Management', testId: 'learning-knowledge-management-icon' }, | ||
{ name: 'Miscellaneous', testId: 'miscellaneous-icon' }, | ||
{ name: 'Uncategorized', testId: 'uncategorized-icon' }, | ||
{ name: 'Unknown', testId: 'default-icon' }, | ||
]; | ||
|
||
categories.forEach(({ name, testId }) => { | ||
test(`renders correct icon for ${name}`, () => { | ||
render(<CategoryIcon category={name} size={48} />); | ||
const icon = screen.queryByTestId(testId) | ||
expect(icon).toBeInTheDocument(); | ||
expect(icon).toHaveAttribute('width', '48'); | ||
expect(icon).toHaveAttribute('height', '48'); | ||
}); | ||
}); | ||
}); |
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,13 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Divider from './Divider'; | ||
|
||
describe('Divider Component', () => { | ||
it('renders the Divider component', () => { | ||
render(<Divider />); | ||
|
||
// Check if the HR.Trimmed component is rendered | ||
expect(screen.getByRole('separator')).toBeInTheDocument(); | ||
}); | ||
}); |
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,27 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Faqs from './Faq'; | ||
|
||
const mockFaqs = [ | ||
{ | ||
question: 'What is your return policy?', | ||
answer: 'You can return any item within 30 days of purchase.', | ||
}, | ||
{ | ||
question: 'How do I track my order?', | ||
answer: 'You can track your order using the tracking number provided in your order confirmation email.', | ||
}, | ||
]; | ||
|
||
describe('Faqs Component', () => { | ||
it('renders the Faqs component', () => { | ||
render(<Faqs faqs={mockFaqs} />); | ||
|
||
// Check if the FAQ questions and answers are rendered | ||
mockFaqs.forEach((faq) => { | ||
expect(screen.getByText(faq.question)).toBeInTheDocument(); | ||
expect(screen.getByText(faq.answer)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
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,64 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Favorites from './Favorites'; | ||
import { setFavorite, unsetFavorite } from '../utils/favorites'; | ||
|
||
jest.mock('../utils/favorites', () => ({ | ||
setFavorite: jest.fn(), | ||
unsetFavorite: jest.fn(), | ||
})); | ||
|
||
Object.assign(navigator, { | ||
clipboard: { | ||
writeText: jest.fn(), | ||
}, | ||
}); | ||
|
||
describe('Favorites', () => { | ||
const plugin = { pluginId: 'test-plugin' }; | ||
const setFavorites = jest.fn(); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('renders favorite button when not favorite', () => { | ||
render(<Favorites isFavorite={false} plugin={plugin} setFavorites={setFavorites} />); | ||
expect(screen.getByText('favorite')).toBeInTheDocument(); | ||
}); | ||
|
||
test('renders unfavorite button when favorite', () => { | ||
render(<Favorites isFavorite={true} plugin={plugin} setFavorites={setFavorites} />); | ||
expect(screen.getByText('unfavorite')).toBeInTheDocument(); | ||
}); | ||
|
||
test('calls setFavorite when favorite button is clicked', () => { | ||
render(<Favorites isFavorite={false} plugin={plugin} setFavorites={setFavorites} />); | ||
fireEvent.click(screen.getByText('favorite')); | ||
expect(setFavorite).toHaveBeenCalledWith(plugin.pluginId, setFavorites); | ||
}); | ||
|
||
test('calls unsetFavorite when unfavorite button is clicked', () => { | ||
render(<Favorites isFavorite={true} plugin={plugin} setFavorites={setFavorites} />); | ||
fireEvent.click(screen.getByText('unfavorite')); | ||
expect(unsetFavorite).toHaveBeenCalledWith(plugin.pluginId, setFavorites); | ||
}); | ||
|
||
test('copies link to clipboard when share button is clicked', () => { | ||
render(<Favorites isFavorite={false} plugin={plugin} setFavorites={setFavorites} />); | ||
fireEvent.click(screen.getByText('share')); | ||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith( | ||
'http://localhost:4000/plugins/test-plugin' | ||
); | ||
}); | ||
|
||
test('displays "copied link to clipboard" after share button is clicked', () => { | ||
render(<Favorites isFavorite={false} plugin={plugin} setFavorites={setFavorites} />); | ||
fireEvent.click(screen.getByText('share')); | ||
expect(screen.getByText('copied link to clipboard')).toBeInTheDocument(); | ||
// expect(navigator.clipboard.writeText).toHaveBeenCalledWith( | ||
// 'http://localhost:4000/plugins/test-plugin' | ||
// ); | ||
}); | ||
}); |
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
Oops, something went wrong.