diff --git a/src/List/__tests__/__snapshots__/index.spec.tsx.snap b/src/List/__tests__/__snapshots__/index.spec.tsx.snap new file mode 100644 index 0000000..4d42ee4 --- /dev/null +++ b/src/List/__tests__/__snapshots__/index.spec.tsx.snap @@ -0,0 +1,20 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`List List render correctly 1`] = ` +
+
+ + title + +
+
+`; diff --git a/src/List/__tests__/index.spec.tsx b/src/List/__tests__/index.spec.tsx new file mode 100644 index 0000000..4c8cc40 --- /dev/null +++ b/src/List/__tests__/index.spec.tsx @@ -0,0 +1,86 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import List from '@/List'; +import toJson from 'enzyme-to-json'; + +const { Item } = List; + +describe('List', () => { + it('List render correctly', () => { + const wrapper = shallow( + + + title + + , + ); + + expect(toJson(wrapper)).toMatchSnapshot(); + }); + describe('renderHeader', () => { + it('renderHeader is string', () => { + const wrapper = shallow(); + + expect(wrapper.find('.h-list-header').text()).toBe('renderHeader'); + }); + + it('renderHeader is function', () => { + const wrapper = shallow( 'renderHeader'} />); + + expect(wrapper.find('.h-list-header').text()).toBe('renderHeader'); + }); + }); + describe('renderFooter', () => { + it('renderFooter is string', () => { + const wrapper = shallow(); + + expect(wrapper.find('.h-list-footer').text()).toBe('renderFooter'); + }); + + it('renderFooter is function', () => { + const wrapper = shallow( 'renderFooter'} />); + + expect(wrapper.find('.h-list-footer').text()).toBe('renderFooter'); + }); + }); + describe('ListItem', () => { + it('subtitle', () => { + const wrapper = shallow(); + + expect(wrapper.find('.h-list-item-subtitle').text()).toBe('subtitle'); + }); + + it('extra', () => { + const wrapper = shallow(); + + expect(wrapper.find('.h-list-item-extra').text()).toBe('extra'); + }); + + it('arrow', () => { + const wrapper = shallow(); + + expect(wrapper.find('.icon-arrow-right')).toBeTruthy(); + }); + + it('thumb', () => { + const wrapper = shallow( + , + ); + + expect(wrapper.find('.h-list-item-thumb').find('img')).toBeTruthy(); + }); + + it('onPress', () => { + const onPress = jest.fn(); + const wrapper = shallow(); + wrapper.simulate('press'); + + expect(onPress).toBeCalled(); + }); + }); +});