UNPKG

react-native-cross-components

Version:
1 lines 4.95 kB
{"file":"/Users/thomas/Source/react-native-core/source/components/input/CrossEditor.test.tsx","mappings":";;;;;AAMA,kBAAkB;AAClB,gCAAgC;AAChC,gCAAgC;AAChC,0CAA0C;AAC1C,mCAAmC;AACnC,MAAM;AACN,gCAAgC;AAChC,mBAAmB;AACnB,gCAAgC;AAChC,iDAAiD;AACjD,8BAA8B;AAC9B,qCAAqC;AACrC,SAAS;AACT,OAAO;AACP,IAAI;AAEJ,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC5B,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAC7B,IAAI,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7C,aAAa,EAAE,EAEd;IACD,kBAAkB,EAAE;QAChB,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE;QACvB,QAAQ,EAAE,EAAE;KACf;CACF,CAAC,CAAC,CAAA;AAnCH,uGAAuG;AACvG,kDAA0B;AAC1B,+CAA+D;AAC/D,8EAA+C;AAkC/C;;;;;;KAMK;AACL,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC/B,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;YAC7C,MAAM,SAAS,GAAsB,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YACvD,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;gBAC/B,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;gBAC5D,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;YAC9C,wCAAwC;YACxC,6BAA6B;YAC7B,gDAAgD;YAChD,MAAM;YAEN,qEAAqE;YACrE,6BAA6B;YAC7B,kEAAkE;YAClE,6CAA6C;YAC7C,MAAM;YAEN,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;gBACzD,IAAI,OAAO,GAAuB,SAAS,CAAC;gBAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC;gBACzB,MAAM,SAAS,GAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;gBAC3D,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;gBAElD,MAAM,OAAO,GAAG,6BAAY,CAAC,MAAM,CACjC,8BAAC,yBAAW,IACV,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,QAAQ,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,eAAe,GACtB,CACH,CAAC;gBAEF,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBAClD,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBAE3C,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","names":[],"sources":["/Users/thomas/Source/react-native-core/source/components/input/CrossEditor.test.tsx"],"sourcesContent":["// https://itnext.io/testing-react-16-3-components-with-react-test-renderer-without-enzyme-d9c65d689e88\nimport React from 'react';\nimport { ICrossEditorProps, CrossEditor } from './CrossEditor';\nimport TestRenderer from 'react-test-renderer';\nimport { TextInputMaskProps } from 'react-native-masked-text';\n\n// function setup(\n// label?: string | undefined,\n// value?: string | undefined,\n// onChangeText?: (val: string) => void,\n// maskProps?: TextInputMaskProps\n// ) {\n// return TestRenderer.create(\n// <CrossEditor\n// label={label || 'Test'}\n// onChangeText={onChangeText || jest.fn()}\n// maskProps={maskProps}\n// value={value || 'Textvalue'}\n// />\n// );\n// }\n\njest.unmock('react-native');\njest.unmock('./CrossEditor');\njest.mock('react-native-masked-inpiut', () => ({\n TextInputMask: {\n \n }, \n TextInputMaskProps: {\n type: '',\n options: {},\n checkText: true,\n onChangeText: jest.fn(),\n refInput: {}\n }\n}))\n\n/**\n * Test component rendering. Properties of children might be tested by importing their type:\n *```\n const btn = wrapper.root.findByType(Button); // or findByProps({ mode: 'text' });\n expect(btn.props.title).toBe('child');\n ```\n */\ndescribe('components', () => {\n describe('<CrossEditor />', () => {\n describe('`ICrossEditorProps` interface', () => {\n const propsMock: ICrossEditorProps = { label: 'Test' };\n it('Should match snapshot', () => {\n expect(propsMock).toMatchSnapshot();\n });\n\n it('Should have `maskProps` property that is undefined', () => {\n expect(propsMock.maskProps).toBeUndefined();\n });\n });\n\n describe('With `label` property provided', () => {\n // it('Component should render', () => {\n // const wrapper = setup();\n // expect(wrapper.toJSON()).toMatchSnapshot();\n // });\n\n // it('Should have paper <TextInput /> with mode \"outlined\"', () => {\n // const wrapper = setup();\n // const child = wrapper.root.findByProps({ mode: 'outlined' });\n // expect(child.type).toEqual('TextInput');\n // });\n\n it('<TextInputMask /> onChangeText should be called', () => {\n let gotText: string | undefined = undefined;\n const textVal = '111333';\n const maskProps: TextInputMaskProps = { type: 'zip-code' };\n const onCalled = (val: string) => (gotText = val);\n\n const wrapper = TestRenderer.create(\n <CrossEditor\n label={'Test'}\n onChangeText={onCalled}\n maskProps={maskProps}\n value={'default value'}\n />\n );\n \n const child = wrapper.root.findByProps(maskProps);\n child.instance.props.onChangeText(textVal);\n\n expect(gotText).toEqual(textVal);\n });\n });\n });\n});\n"],"version":3}