|
| 1 | +import React from 'react'; |
| 2 | +// import ReactDOM from 'react-dom'; |
| 3 | +import Renderer from 'react-test-renderer/shallow'; |
| 4 | +import TU from 'react-dom/test-utils'; |
| 5 | +import Winner from 'components/challenge-detail/Winners/Winner'; |
| 6 | + |
| 7 | +const mockData = { |
| 8 | + isDesign: false, |
| 9 | + isMM: true, |
| 10 | + prizes: [ |
| 11 | + { value: 200, type: 'USD' }, |
| 12 | + { value: 100, type: 'USD' }, |
| 13 | + ], |
| 14 | + submissions: [ |
| 15 | + { |
| 16 | + placement: 1, |
| 17 | + createdBy: 'test', |
| 18 | + created: '2017-11-06T15:49:35.000Z', |
| 19 | + id: '1', |
| 20 | + }, |
| 21 | + { |
| 22 | + placement: 1, |
| 23 | + createdBy: 'test', |
| 24 | + created: '2017-12-06T15:49:35.000Z', |
| 25 | + id: '2', |
| 26 | + }, |
| 27 | + { |
| 28 | + placement: 1, |
| 29 | + createdBy: 'test2', |
| 30 | + created: '2017-11-06T15:49:35.000Z', |
| 31 | + id: '3', |
| 32 | + }, |
| 33 | + ], |
| 34 | + viewable: false, |
| 35 | + winner: { |
| 36 | + handle: 'test', |
| 37 | + placement: 1, |
| 38 | + }, |
| 39 | + isLoggedIn: true, |
| 40 | + auth: { |
| 41 | + tokenV3: 'tokenV3', |
| 42 | + }, |
| 43 | +}; |
| 44 | + |
| 45 | +describe('Matches shallow shapshot', () => { |
| 46 | + test('shapshot 1', () => { |
| 47 | + const renderer = new Renderer(); |
| 48 | + |
| 49 | + renderer.render(( |
| 50 | + <Winner {...mockData} /> |
| 51 | + )); |
| 52 | + expect(renderer.getRenderOutput()).toMatchSnapshot(); |
| 53 | + }); |
| 54 | +}); |
| 55 | + |
| 56 | +class Wrapper extends React.Component { |
| 57 | + componentDidMount() {} |
| 58 | + |
| 59 | + render() { |
| 60 | + return <Winner {...this.props} />; |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +describe('render properly', () => { |
| 65 | + test('click', () => { |
| 66 | + const instance = TU.renderIntoDocument((<Wrapper {...mockData} />)); |
| 67 | + const matches = TU.scryRenderedDOMComponentsWithTag(instance, 'button'); |
| 68 | + expect(matches).toHaveLength(1); |
| 69 | + TU.Simulate.click(matches[0]); |
| 70 | + }); |
| 71 | +}); |
0 commit comments