From b72a5d0a66bddffb7c4b6a8c9a8ed60b1a15bbde Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 20 Aug 2018 16:53:48 +0200 Subject: [PATCH] Improved ServerDropdown.text.js --- src/servers/ServersDropdown.js | 5 ++++- test/servers/ServersDropdown.test.js | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/servers/ServersDropdown.js b/src/servers/ServersDropdown.js index cd345cc7..68ecf85e 100644 --- a/src/servers/ServersDropdown.js +++ b/src/servers/ServersDropdown.js @@ -34,7 +34,10 @@ export class ServersDropdown extends React.Component { ))} - + Export servers diff --git a/test/servers/ServersDropdown.test.js b/test/servers/ServersDropdown.test.js index dde12a82..6c8a90eb 100644 --- a/test/servers/ServersDropdown.test.js +++ b/test/servers/ServersDropdown.test.js @@ -13,11 +13,26 @@ describe('', () => { }); afterEach(() => wrapped.unmount()); - it('contains the list of servers', () => { - expect(wrapped.find(DropdownItem).length).toEqual(servers.length + 2); + it('contains the list of servers', () => + 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', () => { - expect(wrapped.find(DropdownToggle).length).toEqual(1); + it('contains a message when no servers exist yet', () => { + wrapped = shallow(); + 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...'); }); });