This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added testcases for stream_types object
- Loading branch information
1 parent
ade327e
commit 252d03f
Showing
9 changed files
with
267 additions
and
52 deletions.
There are no files selected for viewing
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
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
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
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
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
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
67 changes: 67 additions & 0 deletions
67
...piexplorer/Schema/RecursiveContent/StreamTypesObject/__tests__/StreamTypesObject.test.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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { screen, render } from '@testing-library/react'; | ||
import StreamTypesObject from '..'; | ||
|
||
describe('StreamTypesObject', () => { | ||
const json_schema = { | ||
stream_types: { | ||
description: 'This stream_types description', | ||
type: 'string', | ||
enum: [ | ||
'balance', | ||
'candles', | ||
'cashier_payments', | ||
'p2p_advert', | ||
'p2p_advertiser', | ||
'p2p_order', | ||
'proposal', | ||
'proposal_open_contract', | ||
'ticks', | ||
'transaction', | ||
'trading_platform_asset_listing', | ||
'website_status', | ||
'p2p_settings', | ||
'crypto_estimations', | ||
], | ||
}, | ||
}; | ||
|
||
it('should render button that opens jsonschema', async () => { | ||
render(<StreamTypesObject definitions={json_schema} />); | ||
|
||
const schema_button = await screen.findByText('{}'); | ||
|
||
expect(schema_button).toBeVisible(); | ||
|
||
await userEvent.click(schema_button); | ||
|
||
const schema = await screen.findByTitle('JSON'); | ||
expect(schema).toBeVisible(); | ||
}); | ||
|
||
it('should render the header of the object', () => { | ||
render(<StreamTypesObject definitions={json_schema} />); | ||
|
||
const header_title = screen.getAllByText(/stream_types/)[0]; | ||
expect(header_title).toBeInTheDocument(); | ||
|
||
const header_description = screen.getByText(/This stream_types description/i); | ||
expect(header_description).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the body of StreamTypesObject', () => { | ||
render(<StreamTypesObject definitions={json_schema} />); | ||
|
||
const type = screen.getByText(/enum/i); | ||
expect(type).toBeInTheDocument(); | ||
|
||
const enum_type = screen.getByText(/string/i); | ||
expect(enum_type).toBeInTheDocument(); | ||
|
||
json_schema.stream_types.enum.map((item) => { | ||
const enum_name = screen.getByText(item); | ||
expect(enum_name).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.