Skip to content

Commit 86716db

Browse files
ben.durrantmarkerikson
authored andcommitted
fix tests
1 parent a60a105 commit 86716db

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

test/hooks/useSelector.spec.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import React, {
77
useState,
88
useContext,
99
} from 'react'
10-
import { createStore } from 'redux'
10+
import { Action, createStore } from 'redux'
1111
import * as rtl from '@testing-library/react'
1212
import {
13-
Provider as ProviderMock,
13+
Provider,
14+
ProviderProps,
1415
useSelector,
1516
useDispatch,
1617
shallowEqual,
@@ -26,6 +27,15 @@ import type {
2627
import type { FunctionComponent, DispatchWithoutAction, ReactNode } from 'react'
2728
import type { Store, AnyAction } from 'redux'
2829

30+
// most of these tests depend on selectors being run once, which stabilityCheck doesn't do
31+
// rather than specify it every time, let's make a new "default" here
32+
function ProviderMock<A extends Action<any> = AnyAction, S = unknown>({
33+
stabilityCheck = 'never',
34+
...props
35+
}: ProviderProps<A, S>) {
36+
return <Provider {...props} stabilityCheck={stabilityCheck} />
37+
}
38+
2939
const IS_REACT_18 = React.version.startsWith('18')
3040

3141
describe('React', () => {
@@ -349,7 +359,7 @@ describe('React', () => {
349359
numCalls += 1
350360
return s.count
351361
}
352-
const renderedItems = []
362+
const renderedItems: number[] = []
353363

354364
const Comp = () => {
355365
const value = useSelector(selector)
@@ -387,7 +397,7 @@ describe('React', () => {
387397
numCalls += 1
388398
return s.count
389399
}
390-
const renderedItems = []
400+
const renderedItems: number[] = []
391401

392402
const Child = () => {
393403
useLayoutEffect(() => {
@@ -746,21 +756,21 @@ describe('React', () => {
746756
null as any
747757
)
748758
const useCustomSelector = createSelectorHook(nestedContext)
749-
let defaultCount = null
750-
let customCount = null
759+
let defaultCount: number | null = null
760+
let customCount: number | null = null
751761

752762
const getCount = (s: StateType) => s.count
753763

754764
const DisplayDefaultCount = ({ children = null }) => {
755-
const count = useSelector<StateType>(getCount)
765+
const count = useSelector(getCount)
756766
defaultCount = count
757767
return <>{children}</>
758768
}
759769
interface DisplayCustomCountType {
760770
children: ReactNode
761771
}
762772
const DisplayCustomCount = ({ children }: DisplayCustomCountType) => {
763-
const count = useCustomSelector<StateType>(getCount)
773+
const count = useCustomSelector(getCount)
764774
customCount = count
765775
return <>{children}</>
766776
}

0 commit comments

Comments
 (0)