From e66928565260800320c4b8983d4f3bf18b445bbf Mon Sep 17 00:00:00 2001 From: Harsh Vador <58542468+harsh-vador@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:46:09 +0530 Subject: [PATCH] test: unit test case of Notification feed card (#15267) --- .../NotificationFeedCard.test.tsx | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 openmetadata-ui/src/main/resources/ui/src/components/NotificationBox/NotificationFeedCard.test.tsx diff --git a/openmetadata-ui/src/main/resources/ui/src/components/NotificationBox/NotificationFeedCard.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/NotificationBox/NotificationFeedCard.test.tsx new file mode 100644 index 00000000000..1532af4458c --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/NotificationBox/NotificationFeedCard.test.tsx @@ -0,0 +1,63 @@ +/* + * Copyright 2024 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { act, render, screen } from '@testing-library/react'; +import React from 'react'; +import { ThreadType } from '../../generated/api/feed/createThread'; +import NotificationFeedCard from './NotificationFeedCard.component'; + +jest.mock('../../utils/date-time/DateTimeUtils', () => ({ + formatDateTime: jest.fn().mockImplementation((date) => date), + getRelativeTime: jest.fn().mockImplementation((date) => date), +})); +jest.mock('../../utils/FeedUtils', () => ({ + entityDisplayName: jest.fn().mockReturnValue('database.schema.table'), + prepareFeedLink: jest.fn().mockReturnValue('entity-link'), +})); +jest.mock('../../utils/TasksUtils', () => ({ + getTaskDetailPath: jest.fn().mockReturnValue('/'), +})); +jest.mock('../common/ProfilePicture/ProfilePicture', () => { + return jest + .fn() + .mockReturnValue(
ProfilePicture
); +}); +jest.mock('react-router-dom', () => ({ + Link: jest + .fn() + .mockImplementation(({ children }: { children: React.ReactNode }) => ( +{children}
+ )), +})); +const mockThread = { + about: 'test', + id: '33873393-bd68-46e9-bccc-7701c1c41ad6', + message: 'f93d08e9-2d38-4d01-a294-f8b44fbb0f4a', +}; + +const mockProps = { + createdBy: 'admin', + entityType: 'task', + entityFQN: 'test', + task: mockThread, + feedType: ThreadType.Task, +}; + +describe('Test NotificationFeedCard Component', () => { + it('Check if it has all child elements', async () => { + await act(async () => { + render(