Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinav Kumar <[email protected]>
  • Loading branch information
abhinavkrin committed Oct 28, 2024
1 parent 087723f commit 04ef147
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions apps/meteor/client/views/admin/customEmoji/CustomEmoji.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { mockAppRoot } from '@rocket.chat/mock-providers';
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';

import '@testing-library/jest-dom';

import CustomEmoji from './CustomEmoji';

const appRoot = mockAppRoot().withEndpoint('GET', '/v1/emoji-custom.all', () => ({
count: 1,
offset: 0,
total: 1,
success: true,
emojis: [
{
_id: '1',
name: 'smile',
aliases: ['happy', 'joy'],
extension: 'webp',
_updatedAt: new Date().toISOString(),
etag: 'abcdef',
},
],
}));

describe('CustomEmoji Component', () => {
const mockRef = { current: jest.fn() };
const mockOnClick = jest.fn();

it('renders emoji list', async () => {
render(<CustomEmoji onClick={mockOnClick} reload={mockRef} />, {
legacyRoot: true,
wrapper: appRoot.build(),
});

await waitFor(() => {
expect(screen.getByText('smile')).toBeInTheDocument();
});
});

it("renders emoji's aliases as comma-separated values", async () => {
render(<CustomEmoji onClick={mockOnClick} reload={mockRef} />, {
legacyRoot: true,
wrapper: appRoot.build(),
});

await waitFor(() => {
expect(screen.getByText('happy, joy')).toBeInTheDocument();
});
});
});

0 comments on commit 04ef147

Please sign in to comment.