Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adding tests for template websockets components #1351

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { FileHeaderInfo } from '../../components/FileHeaderInfo';

describe('testing of FileHeaderInfo function', () => {
jest.setTimeout(100000);

const mockData = {
info: {
title: () => 'Test AsyncAPI Service',
version: () => '1.0.0'
},
server: {
protocol: () => 'mqtt',
host: () => 'test.mosquitto.org',
pathname: () => '/mqtt',
hasPathname: () => true
},
serverWithoutPath: {
protocol: () => 'mqtt',
host: () => 'test.mosquitto.org',
pathname: () => '',
hasPathname: () => false
}
};

test('render websockets file header info correctly', () => {
const wrapper = FileHeaderInfo({ info: mockData.info, server: mockData.server });
expect(wrapper).toMatchSnapshot();
});

test('render websockets file header when path is missing', () => {
const wrapper = FileHeaderInfo({ info: mockData.info, server: mockData.serverWithoutPath });
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Requires } from '../../components/Requires';

describe('testing of requires function', () => {
jest.setTimeout(100000);

test('render websockts require statement correctly', () => {
const wrapper = Requires();
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`testing of FileHeaderInfo function render websockets file header info correctly 1`] = `
<Text>
<Text>
//////////////////////////////////////////////////////////////////////
</Text>
<Text>
//
</Text>
<Text>
//

Test AsyncAPI Service
-
1.0.0
</Text>
<Text>
//
Protocol:
mqtt
</Text>
<Text>
//
Host:
test.mosquitto.org
</Text>
<Text>
//
Path:
/mqtt
</Text>
<Text>
//
</Text>
<Text>
//////////////////////////////////////////////////////////////////////
</Text>
</Text>
`;

exports[`testing of FileHeaderInfo function render websockets file header when path is missing 1`] = `
<Text>
<Text>
//////////////////////////////////////////////////////////////////////
</Text>
<Text>
//
</Text>
<Text>
//

Test AsyncAPI Service
-
1.0.0
</Text>
<Text>
//
Protocol:
mqtt
</Text>
<Text>
//
Host:
test.mosquitto.org
</Text>
<Text>
//
</Text>
<Text>
//////////////////////////////////////////////////////////////////////
</Text>
</Text>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`testing of requires function render websockts require statement correctly 1`] = `
<Text>
<Text>
const WebSocket = require('ws');
</Text>
</Text>
`;