Skip to content

test(label-list-item): Add missing tests for LabelListItem component #818

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

Merged
merged 1 commit into from
Oct 4, 2018
Merged
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
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,15 @@
"contributions": [
"code"
]
},
{
"login": "MarioArnt",
"name": "Mario Arnautou",
"avatar_url": "https://avatars2.githubusercontent.com/u/10983824?v=4",
"profile": "http://mario.arnautou.fr/",
"contributions": [
"code"
]
}
],
"repoType": "github"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Thank you to all the people who have already contributed to GitPoint!
| [<img src="https://avatars3.githubusercontent.com/u/5467717?v=4" width="100px;"/><br /><sub><b>Serhii Baraniuk</b></sub>](https://www.facebook.com/serhii.baraniuk)<br />[⚠️](https://github.com/gitpoint/git-point/commits?author=kenitive "Tests") | [<img src="https://avatars2.githubusercontent.com/u/57701?v=4" width="100px;"/><br /><sub><b>Ben Snider</b></sub>](http://www.bensnider.com/)<br />[⚠️](https://github.com/gitpoint/git-point/commits?author=stupergenius "Tests") | [<img src="https://avatars1.githubusercontent.com/u/23706543?v=4" width="100px;"/><br /><sub><b>Simon Hoyos</b></sub>](https://www.linkedin.com/in/simonhoyos/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=shmesa22 "Code") [🎨](#design-shmesa22 "Design") | [<img src="https://avatars3.githubusercontent.com/u/10438692?v=4" width="100px;"/><br /><sub><b>Damien Leroy</b></sub>](https://github.com/ShiiFu)<br />[🌍](#translation-ShiiFu "Translation") | [<img src="https://avatars1.githubusercontent.com/u/686676?v=4" width="100px;"/><br /><sub><b>botbotbot</b></sub>](http://dev.im-bot.com)<br />[⚠️](https://github.com/gitpoint/git-point/commits?author=ibotdotout "Tests") | [<img src="https://avatars1.githubusercontent.com/u/8254906?v=4" width="100px;"/><br /><sub><b>Dmytro Kytsmen</b></sub>](https://github.com/Kietzmann)<br />[🌍](#translation-Kietzmann "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/3683673?v=4" width="100px;"/><br /><sub><b>TheCodeTalker</b></sub>](https://thecodetalker.github.io/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=TheCodeTalker "Code") | [<img src="https://avatars0.githubusercontent.com/u/2670744?v=4" width="100px;"/><br /><sub><b>Leonardo</b></sub>](https://github.com/LeoCp)<br />[💻](https://github.com/gitpoint/git-point/commits?author=LeoCp "Code") | [<img src="https://avatars2.githubusercontent.com/u/13105865?v=4" width="100px;"/><br /><sub><b>Stephen</b></sub>](https://github.com/coderste)<br />[📖](https://github.com/gitpoint/git-point/commits?author=coderste "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/5565340?v=4" width="100px;"/><br /><sub><b>Zahra Traboulsi</b></sub>](http://www.zahra.tech)<br />[💻](https://github.com/gitpoint/git-point/commits?author=ZahraTee "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=ZahraTee "Tests") | [<img src="https://avatars3.githubusercontent.com/u/13391685?v=4" width="100px;"/><br /><sub><b>Joseba Carral</b></sub>](http://codevs.es)<br />[🌍](#translation-jcarral "Translation") | [<img src="https://avatars2.githubusercontent.com/u/5800039?v=4" width="100px;"/><br /><sub><b>CTownsdin</b></sub>](https://github.com/CTownsdin)<br />[💻](https://github.com/gitpoint/git-point/commits?author=CTownsdin "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/7470681?v=4" width="100px;"/><br /><sub><b>Apostolis Economou</b></sub>](https://github.com/apoeco)<br />[💻](https://github.com/gitpoint/git-point/commits?author=apoeco "Code") | [<img src="https://avatars3.githubusercontent.com/u/9337254?v=4" width="100px;"/><br /><sub><b>Arjun</b></sub>](https://github.com/Arjun-sna)<br />[💻](https://github.com/gitpoint/git-point/commits?author=Arjun-sna "Code") | [<img src="https://avatars1.githubusercontent.com/u/5786033?v=4" width="100px;"/><br /><sub><b>Riccardo</b></sub>](http://rkpasia.github.io)<br />[💻](https://github.com/gitpoint/git-point/commits?author=rkpasia "Code") [🎨](#design-rkpasia "Design") | [<img src="https://avatars3.githubusercontent.com/u/21980965?v=4" width="100px;"/><br /><sub><b>Luong Dang Hai</b></sub>](https://luongdanghai.com/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jarvisluong "Code") | [<img src="https://avatars3.githubusercontent.com/u/1428396?v=4" width="100px;"/><br /><sub><b>Jens Strobel</b></sub>](https://github.com/jstrobel)<br />[🐛](https://github.com/gitpoint/git-point/issues?q=author%3Ajstrobel "Bug reports") [🌍](#translation-jstrobel "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3621147?v=4" width="100px;"/><br /><sub><b>James Gosbell</b></sub>](https://github.com/jamesg1)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jamesg1 "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/11476348?v=4" width="100px;"/><br /><sub><b>Dhanial Rizky Wira Putra</b></sub>](https://github.com/dhamanutd)<br />[💻](https://github.com/gitpoint/git-point/commits?author=dhamanutd "Code") [🎨](#design-dhamanutd "Design") | [<img src="https://avatars1.githubusercontent.com/u/16650066?v=4" width="100px;"/><br /><sub><b>James Logue</b></sub>](https://github.com/jjlljj)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jjlljj "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=jjlljj "Tests") | [<img src="https://avatars0.githubusercontent.com/u/22607072?v=4" width="100px;"/><br /><sub><b>parker lindley</b></sub>](https://github.com/etcetera8)<br />[💻](https://github.com/gitpoint/git-point/commits?author=etcetera8 "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=etcetera8 "Tests") | [<img src="https://avatars2.githubusercontent.com/u/22456673?v=4" width="100px;"/><br /><sub><b>Amanda Tjan</b></sub>](https://github.com/soytjan)<br />[💻](https://github.com/gitpoint/git-point/commits?author=soytjan "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=soytjan "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10307875?v=4" width="100px;"/><br /><sub><b>Richie</b></sub>](https://github.com/whitedogg13)<br />[💻](https://github.com/gitpoint/git-point/commits?author=whitedogg13 "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/11476348?v=4" width="100px;"/><br /><sub><b>Dhanial Rizky Wira Putra</b></sub>](https://github.com/dhamanutd)<br />[💻](https://github.com/gitpoint/git-point/commits?author=dhamanutd "Code") [🎨](#design-dhamanutd "Design") | [<img src="https://avatars1.githubusercontent.com/u/16650066?v=4" width="100px;"/><br /><sub><b>James Logue</b></sub>](https://github.com/jjlljj)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jjlljj "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=jjlljj "Tests") | [<img src="https://avatars0.githubusercontent.com/u/22607072?v=4" width="100px;"/><br /><sub><b>parker lindley</b></sub>](https://github.com/etcetera8)<br />[💻](https://github.com/gitpoint/git-point/commits?author=etcetera8 "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=etcetera8 "Tests") | [<img src="https://avatars2.githubusercontent.com/u/22456673?v=4" width="100px;"/><br /><sub><b>Amanda Tjan</b></sub>](https://github.com/soytjan)<br />[💻](https://github.com/gitpoint/git-point/commits?author=soytjan "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=soytjan "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10307875?v=4" width="100px;"/><br /><sub><b>Richie</b></sub>](https://github.com/whitedogg13)<br />[💻](https://github.com/gitpoint/git-point/commits?author=whitedogg13 "Code") | [<img src="https://avatars2.githubusercontent.com/u/10983824?v=4" width="100px;"/><br /><sub><b>Mario Arnautou</b></sub>](http://mario.arnautou.fr/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=MarioArnt "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
31 changes: 31 additions & 0 deletions __tests__/tests/components/LabelListItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { shallow } from 'enzyme';
import { LabelListItem, LabelButton } from 'components';

const defaultProps = {
label: 'Awesome Label',
removeLabel: () => {},
};

describe('<LabelListItem />', () => {
it('should render component with the correct label', () => {
const wrapper = shallow(<LabelListItem {...defaultProps} />);

expect(wrapper.find(LabelButton)).toHaveLength(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarioArnt can you add a blank line before expect calls here and in other places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Could be a good idea to use a linter for the unit tests code style.

expect(
wrapper.contains(<LabelButton label={defaultProps.label} largeWithTag />)
).toEqual(true);
});

it('should call remove label with correct label when user presses IconContainer', () => {
const removeLabelMock = jest.fn();
defaultProps.removeLabel = removeLabelMock;

const wrapper = shallow(<LabelListItem {...defaultProps} />);

wrapper.find('IconContainer').simulate('press');

expect(wrapper.find('IconContainer')).toHaveLength(1);
expect(removeLabelMock).toHaveBeenCalledWith(defaultProps.label);
});
});
2 changes: 2 additions & 0 deletions src/components/label-list-item.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const IconContainer = styled.TouchableOpacity`
justify-content: center;
`;

IconContainer.displayName = 'IconContainer';

export const LabelListItem = ({ label, removeLabel }: Props) => (
<LabelListItemContainer>
<Wrapper>
Expand Down