-
Notifications
You must be signed in to change notification settings - Fork 51
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
2a43b44
commit 961ff68
Showing
1 changed file
with
18 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 18 additions & 8 deletions
26
src/components/SettingsModal/SettingsView/GraphBlueprint/__tests__/index.tsx
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 |
---|---|---|
@@ -1,22 +1,32 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import { GraphBlueprint } from '../index' | ||
import { render, waitFor } from '@testing-library/react' | ||
import React from 'react' | ||
import { GraphBlueprint } from '..' | ||
|
||
jest.mock('../../../../../network/fetchSourcesData', () => ({ | ||
getSchemaAll: jest.fn().mockResolvedValue({ schemas: [{ type: 'Custom', is_deleted: false }] }), | ||
jest.mock('~/network/fetchSourcesData', () => ({ | ||
getSchemaAll: jest.fn().mockResolvedValue({ | ||
schemas: [{ type: 'Custom', is_deleted: false }], | ||
}), | ||
})) | ||
|
||
describe('GraphBlueprint', () => { | ||
beforeEach(() => { | ||
jest.spyOn(React, 'useState').mockImplementation((initState?: unknown) => [initState, jest.fn()]) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('should display only one Custom node', async () => { | ||
render(<GraphBlueprint />) | ||
const { getAllByText } = render(<GraphBlueprint />) | ||
|
||
const customNodes = await screen.findAllByText('Custom') | ||
;(async () => { | ||
await waitFor(() => { | ||
const customNode = getAllByText('Custom') | ||
|
||
expect(customNodes).toHaveLength(1) | ||
expect(customNode).toHaveLength(1) | ||
}) | ||
})() | ||
}) | ||
}) |