import { shallow, ShallowWrapper } from 'enzyme'; import { ListGroup } from 'reactstrap'; import { Mock } from 'ts-mockery'; import ServersListGroup from '../../src/servers/ServersListGroup'; import { ServerWithId } from '../../src/servers/data'; describe('', () => { let wrapped: ShallowWrapper; const createComponent = (servers: ServerWithId[]) => { wrapped = shallow(The list of servers); return wrapped; }; afterEach(() => wrapped?.unmount()); 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 = [ Mock.of({ name: 'foo', id: '123' }), Mock.of({ name: 'bar', id: '456' }), ]; const wrapped = createComponent(servers); expect(wrapped.find(ListGroup)).toHaveLength(1); expect(wrapped.find('ServerListItem')).toHaveLength(servers.length); }); });