UNPKG

react-native-cross-components

Version:
1 lines 4.69 kB
{"file":"/Users/thomas/Source/react-native-core/source/components/modals/CrossBusyIndicator.test.tsx","mappings":";;;;;AAQA,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC5B,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;AATpC,kDAA0B;AAC1B,8EAA+C;AAC/C,6DAA8D;AAC9D,oDAAuB;AAEvB,8EAA+E;AAC/E,+CAAsD;AAKtD,SAAS,KAAK,CAAC,OAAyC;IACtD,MAAM,KAAK,mBACT,MAAM,EAAE,IAAI,EACZ,qBAAqB,EAAE,IAAI,EAC3B,IAAI,EAAE,+BAAgB,CAAC,aAAa,EACpC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IACrC,OAAO,CACX,CAAC;IAEF,MAAM,OAAO,GAAG,6BAAY,CAAC,MAAM,CAAC,8BAAC,4BAAkB,oBAAK,KAAK,EAAI,CAAC,CAAC;IAEvE,OAAO;QACL,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;YAC5B,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;YAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;gBACxB,IAAI,EAAE,+BAAgB,CAAC,YAAY;gBACnC,MAAM,EAAE,IAAI;gBACZ,qBAAqB,EAAE,IAAI;aAC5B,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW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AAC,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","names":[],"sources":["/Users/thomas/Source/react-native-core/source/components/modals/CrossBusyIndicator.test.tsx"],"sourcesContent":["import React from 'react';\nimport TestRenderer from 'react-test-renderer';\nimport { CrossSpinnerType } from '../animations/CrossSpinner';\nimport _ from 'lodash';\n\nimport CrossBusyIndicator, { IBusyIndicatorProps } from './CrossBusyIndicator';\nimport { TouchableOpacity, Text } from 'react-native';\n\njest.unmock('react-native');\njest.unmock('./CrossBusyIndicator');\n\nfunction setup(options?: IBusyIndicatorProps | undefined) {\n const props: IBusyIndicatorProps = {\n isBusy: true,\n isCancelButtonVisible: true,\n type: CrossSpinnerType.BallIndicator,\n onCancel: () => console.log('Cancelled'),\n ...options,\n };\n\n const wrapper = TestRenderer.create(<CrossBusyIndicator {...props} />);\n\n return {\n props,\n wrapper,\n };\n}\n\ndescribe('components', () => {\n describe('<CrossBusyIndicator />', () => {\n it('Should render self and subcomponents', () => {\n const { wrapper } = setup();\n expect(wrapper.toJSON()).toMatchSnapshot();\n });\n\n it('Should have <CrossSpinner /> of type \"DotIndicator\"', () => {\n const { wrapper } = setup({\n type: CrossSpinnerType.DotIndicator,\n isBusy: true,\n isCancelButtonVisible: true,\n });\n const child = wrapper.root.findByProps({\n type: CrossSpinnerType.DotIndicator,\n });\n expect(child).toBeDefined();\n });\n\n it('Should have <Text /> with value \"Cancel\"', done => {\n const { wrapper } = setup();\n const child = wrapper.root.findAllByType(Text).slice(-1)[0];\n // console.log('text child', child || 'null');\n // console.log('props', child ? child.props : 'none');\n if (_.get(child, ['props', 'children', 'join'])) {\n expect(child.props.children.join()).toContain('Cancel');\n } else{\n done.fail('Could not find Text element') \n }\n });\n\n it('Cancel button onCancel should be called', () => {\n let called = false;\n const onCalled = () => (called = !called);\n\n const { wrapper } = setup({\n type: CrossSpinnerType.DotIndicator,\n isBusy: true,\n isCancelButtonVisible: true,\n onCancel: onCalled,\n });\n\n const child = wrapper.root.findByType(TouchableOpacity);\n child.props.onPress();\n expect(called).toBeTruthy();\n });\n });\n});\n"],"version":3}