|
| 1 | +/* |
| 2 | + * Copyright 2024 Collate. |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | + * Unless required by applicable law or agreed to in writing, software |
| 8 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | + * See the License for the specific language governing permissions and |
| 11 | + * limitations under the License. |
| 12 | + */ |
| 13 | +import { render, screen } from '@testing-library/react'; |
| 14 | +import React from 'react'; |
| 15 | +import OntologyExplorerPage from './OntologyExplorerPage'; |
| 16 | + |
| 17 | +const mockOntologyExplorer = jest.fn(); |
| 18 | + |
| 19 | +jest.mock('@openmetadata/ui-core-components', () => ({ |
| 20 | + Badge: jest |
| 21 | + .fn() |
| 22 | + .mockImplementation(({ children, 'data-testid': testId }) => ( |
| 23 | + <span data-testid={testId}>{children}</span> |
| 24 | + )), |
| 25 | + Card: jest |
| 26 | + .fn() |
| 27 | + .mockImplementation(({ children }: { children: React.ReactNode }) => ( |
| 28 | + <div>{children}</div> |
| 29 | + )), |
| 30 | + Divider: jest.fn().mockImplementation(() => <hr />), |
| 31 | + Skeleton: jest.fn().mockImplementation(() => <div data-testid="skeleton" />), |
| 32 | + Typography: jest |
| 33 | + .fn() |
| 34 | + .mockImplementation( |
| 35 | + ({ |
| 36 | + children, |
| 37 | + 'data-testid': testId, |
| 38 | + }: { |
| 39 | + children: React.ReactNode; |
| 40 | + 'data-testid'?: string; |
| 41 | + }) => <span data-testid={testId}>{children}</span> |
| 42 | + ), |
| 43 | +})); |
| 44 | + |
| 45 | +jest.mock('@untitledui/icons', () => ({ |
| 46 | + Home02: () => <div>Home02</div>, |
| 47 | +})); |
| 48 | + |
| 49 | +jest.mock('../../components/PageLayoutV1/PageLayoutV1', () => ({ |
| 50 | + __esModule: true, |
| 51 | + default: jest.fn(({ children }: { children: React.ReactNode }) => ( |
| 52 | + <div>{children}</div> |
| 53 | + )), |
| 54 | +})); |
| 55 | + |
| 56 | +jest.mock( |
| 57 | + '../../components/common/TitleBreadcrumb/TitleBreadcrumb.component', |
| 58 | + () => ({ |
| 59 | + __esModule: true, |
| 60 | + default: jest.fn(() => <div data-testid="breadcrumb" />), |
| 61 | + }) |
| 62 | +); |
| 63 | + |
| 64 | +jest.mock('../../components/OntologyExplorer', () => ({ |
| 65 | + OntologyExplorer: jest.fn((props) => { |
| 66 | + mockOntologyExplorer(props); |
| 67 | + |
| 68 | + return <div data-testid="ontology-explorer" />; |
| 69 | + }), |
| 70 | +})); |
| 71 | + |
| 72 | +describe('OntologyExplorerPage', () => { |
| 73 | + beforeEach(() => { |
| 74 | + jest.clearAllMocks(); |
| 75 | + }); |
| 76 | + |
| 77 | + it('renders heading with beta badge and all page elements', () => { |
| 78 | + render(<OntologyExplorerPage />); |
| 79 | + |
| 80 | + expect(screen.getByTestId('heading')).toBeInTheDocument(); |
| 81 | + expect(screen.getByTestId('beta-badge')).toBeInTheDocument(); |
| 82 | + expect(screen.getByTestId('beta-badge')).toHaveTextContent('label.beta'); |
| 83 | + expect(screen.getByTestId('breadcrumb')).toBeInTheDocument(); |
| 84 | + expect(screen.getByTestId('ontology-explorer')).toBeInTheDocument(); |
| 85 | + }); |
| 86 | +}); |
0 commit comments