@@ -1761,141 +1761,6 @@ describe('React', () => {
1761
1761
} )
1762
1762
} )
1763
1763
1764
- describe ( 'HMR handling' , ( ) => {
1765
- it . skip ( 'should recalculate the state and rebind the actions on hot update' , ( ) => {
1766
- const store = createStore ( ( ) => { } )
1767
- class ContainerBefore extends Component {
1768
- render ( ) {
1769
- return < Passthrough { ...this . props } />
1770
- }
1771
- }
1772
- const ConnectedContainerBefore = connect ( null , ( ) => ( {
1773
- scooby : 'doo' ,
1774
- } ) ) ( ContainerBefore )
1775
- class ContainerAfter extends Component {
1776
- render ( ) {
1777
- return < Passthrough { ...this . props } />
1778
- }
1779
- }
1780
- const ConnectedContainerAfter = connect (
1781
- ( ) => ( { foo : 'baz' } ) ,
1782
- ( ) => ( { scooby : 'foo' } )
1783
- ) ( ContainerAfter )
1784
- class ContainerNext extends Component {
1785
- render ( ) {
1786
- return < Passthrough { ...this . props } />
1787
- }
1788
- }
1789
- const ConnectedContainerNext = connect (
1790
- ( ) => ( { foo : 'bar' } ) ,
1791
- ( ) => ( { scooby : 'boo' } )
1792
- ) ( ContainerNext )
1793
-
1794
- let container = React . createRef < ContainerBefore > ( )
1795
- const tester = rtl . render (
1796
- < ProviderMock store = { store } >
1797
- < ConnectedContainerBefore ref = { container } />
1798
- </ ProviderMock >
1799
- )
1800
- expect ( tester . queryByTestId ( 'foo' ) ) . toBe ( null )
1801
- expect ( tester . getByTestId ( 'scooby' ) ) . toHaveTextContent ( 'doo' )
1802
- imitateHotReloading (
1803
- ConnectedContainerBefore ,
1804
- ConnectedContainerAfter ,
1805
- container . current !
1806
- )
1807
- expect ( tester . getByTestId ( 'foo' ) ) . toHaveTextContent ( 'baz' )
1808
- expect ( tester . getByTestId ( 'scooby' ) ) . toHaveTextContent ( 'foo' )
1809
- imitateHotReloading (
1810
- ConnectedContainerBefore ,
1811
- ConnectedContainerNext ,
1812
- container . current !
1813
- )
1814
- expect ( tester . getByTestId ( 'foo' ) ) . toHaveTextContent ( 'bar' )
1815
- expect ( tester . getByTestId ( 'scooby' ) ) . toHaveTextContent ( 'boo' )
1816
- } )
1817
-
1818
- it . skip ( 'should persist listeners through hot update' , ( ) => {
1819
- const ACTION_TYPE = 'ACTION'
1820
- interface RootStateType {
1821
- actions : number
1822
- }
1823
- interface ActionType {
1824
- type : string
1825
- }
1826
- const store = createStore (
1827
- ( state : RootStateType = { actions : 0 } , action : ActionType ) => {
1828
- switch ( action . type ) {
1829
- case ACTION_TYPE : {
1830
- return {
1831
- actions : state . actions + 1 ,
1832
- }
1833
- }
1834
- default :
1835
- return state
1836
- }
1837
- }
1838
- )
1839
-
1840
- class Child extends Component {
1841
- render ( ) {
1842
- return < Passthrough { ...this . props } />
1843
- }
1844
- }
1845
- interface ChildrenTStateProps {
1846
- actions : number
1847
- }
1848
- type ChildrenNoDispatch = { }
1849
- type ChildrenTOwnProps = { }
1850
- type ChildrenRootState = RootStateType
1851
- const ConnectedChild = connect <
1852
- ChildrenTStateProps ,
1853
- ChildrenNoDispatch ,
1854
- ChildrenTOwnProps ,
1855
- ChildrenRootState
1856
- > ( ( state ) => ( {
1857
- actions : state . actions ,
1858
- } ) ) ( Child )
1859
-
1860
- class ParentBefore extends Component {
1861
- render ( ) {
1862
- return < ConnectedChild />
1863
- }
1864
- }
1865
- const ConnectedParentBefore = connect ( ( ) => ( { scooby : 'doo' } ) ) (
1866
- ParentBefore
1867
- )
1868
-
1869
- class ParentAfter extends Component {
1870
- render ( ) {
1871
- return < Child />
1872
- }
1873
- }
1874
- const ConnectedParentAfter = connect ( ( ) => ( { scooby : 'boo' } ) ) (
1875
- ParentAfter
1876
- )
1877
-
1878
- let container = React . createRef < ParentBefore > ( )
1879
- const tester = rtl . render (
1880
- < ProviderMock store = { store } >
1881
- < ConnectedParentBefore ref = { container } />
1882
- </ ProviderMock >
1883
- )
1884
-
1885
- imitateHotReloading (
1886
- ConnectedParentBefore ,
1887
- ConnectedParentAfter ,
1888
- container . current !
1889
- )
1890
-
1891
- rtl . act ( ( ) => {
1892
- store . dispatch ( { type : ACTION_TYPE } )
1893
- } )
1894
-
1895
- expect ( tester . getByTestId ( 'actions' ) ) . toHaveTextContent ( '1' )
1896
- } )
1897
- } )
1898
-
1899
1764
describe ( 'Wrapped component and HOC handling' , ( ) => {
1900
1765
it ( 'should throw an error if a component is not passed to the function returned by connect' , ( ) => {
1901
1766
expect ( connect ( ) ) . toThrow ( / Y o u m u s t p a s s a c o m p o n e n t t o t h e f u n c t i o n / )
@@ -2668,39 +2533,6 @@ describe('React', () => {
2668
2533
} )
2669
2534
2670
2535
describe ( 'Refs' , ( ) => {
2671
- // it.skip('should throw when trying to access the wrapped instance if withRef is not specified', () => {
2672
- // const store = createStore(() => ({}))
2673
-
2674
- // class Container extends Component {
2675
- // render() {
2676
- // return <Passthrough />
2677
- // }
2678
- // }
2679
-
2680
- // const decorator = connect((state) => state)
2681
- // const Decorated = decorator(Container)
2682
-
2683
- // class Wrapper extends Component {
2684
- // render() {
2685
- // return (
2686
- // <Decorated ref={(comp) => comp && comp.getWrappedInstance()} />
2687
- // )
2688
- // }
2689
- // }
2690
-
2691
- // // TODO Remove this when React is fixed, per https://github.com/facebook/react/issues/11098
2692
- // const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
2693
- // expect(() =>
2694
- // rtl.render(
2695
- // <ProviderMock store={store}>
2696
- // <Wrapper />
2697
- // </ProviderMock>
2698
- // )
2699
- // ).toThrow(
2700
- // `To access the wrapped instance, you need to specify { withRef: true } in the options argument of the connect() call`
2701
- // )
2702
- // spy.mockRestore()
2703
- // })
2704
2536
it ( 'should return the instance of the wrapped component for use in calling child methods' , async ( done ) => {
2705
2537
const store = createStore ( ( ) => ( { } ) )
2706
2538
0 commit comments