1+ import path from 'path' ;
2+ import { render } from '@asyncapi/generator-react-sdk' ;
3+ import { Parser , fromFile } from '@asyncapi/parser' ;
4+ import { Send } from '../../components/Send' ;
5+
6+ const parser = new Parser ( ) ;
7+ const asyncapi_websocket_query = path . resolve ( __dirname , '../../../../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml' ) ;
8+
9+ describe ( 'Testing of Send component' , ( ) => {
10+ let parsedAsyncAPIDocument ;
11+
12+ beforeAll ( async ( ) => {
13+ const parseResult = await fromFile ( parser , asyncapi_websocket_query ) . parse ( ) ;
14+ parsedAsyncAPIDocument = parseResult . document ;
15+ } ) ;
16+
17+ test ( 'render Send component with send operations' , ( ) => {
18+ const sendOperations = parsedAsyncAPIDocument . operations ( ) . filterBySend ( ) ;
19+ const result = render ( < Send sendOperations = { sendOperations } /> ) ;
20+ const actual = result . trim ( ) ;
21+ expect ( actual ) . toMatchSnapshot ( ) ;
22+ } ) ;
23+
24+ test ( 'renders nothing when send operations is empty' , ( ) => {
25+ const result = render ( < Send sendOperations = { [ ] } /> ) ;
26+ const actual = result . trim ( ) ;
27+ expect ( actual ) . toMatchSnapshot ( ) ;
28+ } ) ;
29+ test ( 'render nothing when send operations is null' , ( ) => {
30+ const result = render ( < Send sendOperations = { null } /> ) ;
31+ const actual = result . trim ( ) ;
32+ expect ( actual ) . toMatchSnapshot ( ) ;
33+ } ) ;
34+ test ( 'renders nothing without send operations' , ( ) => {
35+ const result = render ( < Send /> ) ;
36+ const actual = result . trim ( ) ;
37+ expect ( actual ) . toMatchSnapshot ( ) ;
38+ } ) ;
39+ } ) ;
0 commit comments