2020-08-29 10:19:15 +03:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
2020-03-08 13:16:57 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { ListGroup } from 'reactstrap';
|
2020-08-29 10:19:15 +03:00
|
|
|
import { Mock } from 'ts-mockery';
|
2020-03-08 13:16:57 +03:00
|
|
|
import ServersListGroup from '../../src/servers/ServersListGroup';
|
2020-08-29 10:19:15 +03:00
|
|
|
import { ServerWithId } from '../../src/servers/data';
|
2020-03-08 13:16:57 +03:00
|
|
|
|
|
|
|
describe('<ServersListGroup />', () => {
|
2020-08-29 10:19:15 +03:00
|
|
|
let wrapped: ShallowWrapper;
|
|
|
|
const createComponent = (servers: ServerWithId[]) => {
|
2020-03-08 13:16:57 +03:00
|
|
|
wrapped = shallow(<ServersListGroup servers={servers}>The list of servers</ServersListGroup>);
|
|
|
|
|
|
|
|
return wrapped;
|
|
|
|
};
|
|
|
|
|
2020-08-29 10:19:15 +03:00
|
|
|
afterEach(() => wrapped?.unmount());
|
2020-03-08 13:16:57 +03:00
|
|
|
|
|
|
|
it('Renders title', () => {
|
|
|
|
const wrapped = createComponent([]);
|
|
|
|
const title = wrapped.find('h5');
|
|
|
|
|
|
|
|
expect(title).toHaveLength(1);
|
|
|
|
expect(title.text()).toEqual('The list of servers');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows servers list', () => {
|
|
|
|
const servers = [
|
2020-08-29 10:19:15 +03:00
|
|
|
Mock.of<ServerWithId>({ name: 'foo', id: '123' }),
|
|
|
|
Mock.of<ServerWithId>({ name: 'bar', id: '456' }),
|
2020-03-08 13:16:57 +03:00
|
|
|
];
|
|
|
|
const wrapped = createComponent(servers);
|
|
|
|
|
|
|
|
expect(wrapped.find(ListGroup)).toHaveLength(1);
|
|
|
|
expect(wrapped.find('ServerListItem')).toHaveLength(servers.length);
|
|
|
|
});
|
|
|
|
});
|