Skip to content

Commit c9a5b8f

Browse files
committed
reafctor: delete some obsolete cases that have been skipped
1 parent bc70ffb commit c9a5b8f

File tree

1 file changed

+0
-168
lines changed

1 file changed

+0
-168
lines changed

test/components/connect.spec.tsx

Lines changed: 0 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,141 +1761,6 @@ describe('React', () => {
17611761
})
17621762
})
17631763

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-
18991764
describe('Wrapped component and HOC handling', () => {
19001765
it('should throw an error if a component is not passed to the function returned by connect', () => {
19011766
expect(connect()).toThrow(/You must pass a component to the function/)
@@ -2668,39 +2533,6 @@ describe('React', () => {
26682533
})
26692534

26702535
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-
// })
27042536
it('should return the instance of the wrapped component for use in calling child methods', async (done) => {
27052537
const store = createStore(() => ({}))
27062538

0 commit comments

Comments
 (0)