Improved ServerDropdown.text.js

This commit is contained in:
Alejandro Celaya 2018-08-20 16:53:48 +02:00
parent e0c1e13d1e
commit b72a5d0a66
2 changed files with 23 additions and 5 deletions

View file

@ -34,7 +34,10 @@ export class ServersDropdown extends React.Component {
</DropdownItem> </DropdownItem>
))} ))}
<DropdownItem divider /> <DropdownItem divider />
<DropdownItem onClick={serversExporter.exportServers}> <DropdownItem
onClick={serversExporter.exportServers}
className="servers-dropdown__export-item"
>
Export servers Export servers
</DropdownItem> </DropdownItem>
</React.Fragment> </React.Fragment>

View file

@ -13,11 +13,26 @@ describe('<ServersDropdown />', () => {
}); });
afterEach(() => wrapped.unmount()); afterEach(() => wrapped.unmount());
it('contains the list of servers', () => { it('contains the list of servers', () =>
expect(wrapped.find(DropdownItem).length).toEqual(servers.length + 2); expect(wrapped.find(DropdownItem).filter('[to]')).toHaveLength(servers.length)
);
it('contains a toggle with proper title', () =>
expect(wrapped.find(DropdownToggle)).toHaveLength(1)
);
it('contains a button to export servers', () => {
const items = wrapped.find(DropdownItem);
expect(items.filter('[divider]')).toHaveLength(1);
expect(items.filter('.servers-dropdown__export-item')).toHaveLength(1);
}); });
it('contains a toggle with proper title', () => { it('contains a message when no servers exist yet', () => {
expect(wrapped.find(DropdownToggle).length).toEqual(1); wrapped = shallow(<ServersDropdown servers={[]} listServers={identity} />);
const item = wrapped.find(DropdownItem);
expect(item).toHaveLength(1);
expect(item.prop('disabled')).toEqual(true);
expect(item.find('i').text()).toEqual('Add a server first...');
}); });
}); });