Skip to content

Commit

Permalink
Fix model overview tests
Browse files Browse the repository at this point in the history
  • Loading branch information
a3957273 committed May 9, 2023
1 parent 7f8a9ea commit b9c8880
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions frontend/src/ModelOverview.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { ThemeProvider } from '@mui/material/styles'
import { render, screen, waitFor } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'

import { useGetSchema } from '../data/schema'
import { EntityKind } from '../types/types'
import ModelOverview from './ModelOverview'
import { lightTheme } from './theme'

vi.mock('../data/schema', async () => {
const actual = await vi.importActual('../data/schema')
return {
...(actual as any),
useGetSchema: vi.fn(),
}
})

describe('ModelOverview', () => {
const version: any = {
metadata: {
Expand All @@ -22,6 +32,39 @@ describe('ModelOverview', () => {
}

it('renders a ModelOverview component', async () => {
const mockedSchema: any = {
schema: {
name: 'upload-schema',
reference: 'test-schema',
use: 'UPLOAD',
schema: {
type: 'object',
properties: {
contacts: {
title: 'Contacts',
type: 'object',
properties: {
uploader: {
title: 'Model Developer',
},
reviewer: {
title: 'Model Technical Reviewer',
},
manager: {
title: 'Senior Responsible Officer',
},
},
},
},
},
},

isSchemaLoading: false,
isSchemaError: false,
}

vi.mocked(useGetSchema).mockReturnValue(mockedSchema)

render(
<ThemeProvider theme={lightTheme}>
<ModelOverview version={version} />
Expand Down

0 comments on commit b9c8880

Please sign in to comment.