Skip to content

Commit 7d48677

Browse files
aryaemami59markerikson
authored andcommitted
Change .toHaveBeenCalledTimes(1) to .toHaveBeenCalledOnce()
1 parent b9846b0 commit 7d48677

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

test/components/Provider.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ describe('React', () => {
198198
<WrapperOuter />
199199
</Provider>,
200200
)
201-
expect(innerMapStateToProps).toHaveBeenCalledTimes(1)
201+
expect(innerMapStateToProps).toHaveBeenCalledOnce()
202202

203203
rtl.act(() => {
204204
innerStore.dispatch({ type: 'INC' })
@@ -348,7 +348,7 @@ describe('React', () => {
348348

349349
unmount()
350350

351-
expect(spy).toHaveBeenCalledTimes(1)
351+
expect(spy).toHaveBeenCalledOnce()
352352
})
353353

354354
it('should handle store and children change in a the same render', () => {

test/components/connect.spec.tsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ describe('React', () => {
651651
)}
652652
</ProviderMock>,
653653
)
654-
expect(spy).toHaveBeenCalledTimes(1)
654+
expect(spy).toHaveBeenCalledOnce()
655655
expect(spy.mock.calls[0][0]).toMatch(
656656
/mapStateToProps\(\) in Connect\(Container\) must return a plain object/,
657657
)
@@ -668,7 +668,7 @@ describe('React', () => {
668668
)}
669669
</ProviderMock>,
670670
)
671-
expect(spy).toHaveBeenCalledTimes(1)
671+
expect(spy).toHaveBeenCalledOnce()
672672
expect(spy.mock.calls[0][0]).toMatch(
673673
/mapStateToProps\(\) in Connect\(Container\) must return a plain object/,
674674
)
@@ -685,7 +685,7 @@ describe('React', () => {
685685
)}
686686
</ProviderMock>,
687687
)
688-
expect(spy).toHaveBeenCalledTimes(1)
688+
expect(spy).toHaveBeenCalledOnce()
689689
expect(spy.mock.calls[0][0]).toMatch(
690690
/mapStateToProps\(\) in Connect\(Container\) must return a plain object/,
691691
)
@@ -702,7 +702,7 @@ describe('React', () => {
702702
)}
703703
</ProviderMock>,
704704
)
705-
expect(spy).toHaveBeenCalledTimes(1)
705+
expect(spy).toHaveBeenCalledOnce()
706706
expect(spy.mock.calls[0][0]).toMatch(
707707
/mapDispatchToProps\(\) in Connect\(Container\) must return a plain object/,
708708
)
@@ -719,7 +719,7 @@ describe('React', () => {
719719
)}
720720
</ProviderMock>,
721721
)
722-
expect(spy).toHaveBeenCalledTimes(1)
722+
expect(spy).toHaveBeenCalledOnce()
723723
expect(spy.mock.calls[0][0]).toMatch(
724724
/mapDispatchToProps\(\) in Connect\(Container\) must return a plain object/,
725725
)
@@ -736,7 +736,7 @@ describe('React', () => {
736736
)}
737737
</ProviderMock>,
738738
)
739-
expect(spy).toHaveBeenCalledTimes(1)
739+
expect(spy).toHaveBeenCalledOnce()
740740
expect(spy.mock.calls[0][0]).toMatch(
741741
/mapDispatchToProps\(\) in Connect\(Container\) must return a plain object/,
742742
)
@@ -753,7 +753,7 @@ describe('React', () => {
753753
)}
754754
</ProviderMock>,
755755
)
756-
expect(spy).toHaveBeenCalledTimes(1)
756+
expect(spy).toHaveBeenCalledOnce()
757757
expect(spy.mock.calls[0][0]).toMatch(
758758
/mergeProps\(\) in Connect\(Container\) must return a plain object/,
759759
)
@@ -770,7 +770,7 @@ describe('React', () => {
770770
)}
771771
</ProviderMock>,
772772
)
773-
expect(spy).toHaveBeenCalledTimes(1)
773+
expect(spy).toHaveBeenCalledOnce()
774774
expect(spy.mock.calls[0][0]).toMatch(
775775
/mergeProps\(\) in Connect\(Container\) must return a plain object/,
776776
)
@@ -787,7 +787,7 @@ describe('React', () => {
787787
)}
788788
</ProviderMock>,
789789
)
790-
expect(spy).toHaveBeenCalledTimes(1)
790+
expect(spy).toHaveBeenCalledOnce()
791791
expect(spy.mock.calls[0][0]).toMatch(
792792
/mergeProps\(\) in Connect\(Container\) must return a plain object/,
793793
)
@@ -1488,7 +1488,7 @@ describe('React', () => {
14881488
<ConnectedContainer />
14891489
</ProviderMock>,
14901490
)
1491-
expect(spy).toHaveBeenCalledTimes(1)
1491+
expect(spy).toHaveBeenCalledOnce()
14921492
expect(tester.getByTestId('string')).toHaveTextContent('')
14931493
rtl.act(() => {
14941494
store.dispatch({ type: 'APPEND', body: 'a' })
@@ -1583,7 +1583,7 @@ describe('React', () => {
15831583
}
15841584

15851585
const tester = rtl.render(<Root />)
1586-
expect(spy).toHaveBeenCalledTimes(1)
1586+
expect(spy).toHaveBeenCalledOnce()
15871587
expect(tester.getByTestId('string')).toHaveTextContent('')
15881588
expect(tester.getByTestId('pass')).toHaveTextContent('')
15891589

@@ -2051,7 +2051,7 @@ describe('React', () => {
20512051
</ProviderMock>,
20522052
)
20532053

2054-
expect(mapStateToProps).toHaveBeenCalledTimes(1)
2054+
expect(mapStateToProps).toHaveBeenCalledOnce()
20552055
rtl.act(() => {
20562056
store.dispatch({ type: 'INC' })
20572057
})
@@ -2114,11 +2114,11 @@ describe('React', () => {
21142114
rtl.act(() => {
21152115
store.dispatch({ type: 'INC' })
21162116
})
2117-
expect(mapStateToProps).toHaveBeenCalledTimes(1)
2117+
expect(mapStateToProps).toHaveBeenCalledOnce()
21182118
rtl.act(() => {
21192119
store.dispatch({ type: 'INC' })
21202120
})
2121-
expect(mapStateToProps).toHaveBeenCalledTimes(1)
2121+
expect(mapStateToProps).toHaveBeenCalledOnce()
21222122
})
21232123
})
21242124

@@ -2381,9 +2381,9 @@ describe('React', () => {
23812381
expect(tester.getByTestId('b')).toHaveTextContent('3')
23822382
expect(tester.getByTestId('c')).toHaveTextContent('1')
23832383

2384-
expect(c3Spy).toHaveBeenCalledTimes(1)
2385-
expect(c2Spy).toHaveBeenCalledTimes(1)
2386-
expect(c1Spy).toHaveBeenCalledTimes(1)
2384+
expect(c3Spy).toHaveBeenCalledOnce()
2385+
expect(c2Spy).toHaveBeenCalledOnce()
2386+
expect(c1Spy).toHaveBeenCalledOnce()
23872387

23882388
rtl.act(() => {
23892389
store1.dispatch({ type: 'CHANGE' })
@@ -2395,7 +2395,7 @@ describe('React', () => {
23952395
expect(tester.getByTestId('c')).toHaveTextContent('2')
23962396

23972397
expect(c3Spy).toHaveBeenCalledTimes(2)
2398-
expect(c2Spy).toHaveBeenCalledTimes(1)
2398+
expect(c2Spy).toHaveBeenCalledOnce()
23992399
expect(c1Spy).toHaveBeenCalledTimes(2)
24002400

24012401
rtl.act(() => {
@@ -2485,16 +2485,16 @@ describe('React', () => {
24852485
</ProviderMock>
24862486
</ProviderMock>,
24872487
)
2488-
expect(mapStateToPropsB).toHaveBeenCalledTimes(1)
2489-
expect(mapStateToPropsC).toHaveBeenCalledTimes(1)
2490-
expect(mapStateToPropsD).toHaveBeenCalledTimes(1)
2488+
expect(mapStateToPropsB).toHaveBeenCalledOnce()
2489+
expect(mapStateToPropsC).toHaveBeenCalledOnce()
2490+
expect(mapStateToPropsD).toHaveBeenCalledOnce()
24912491

24922492
rtl.act(() => {
24932493
store1.dispatch({ type: 'INC' })
24942494
})
24952495

2496-
expect(mapStateToPropsB).toHaveBeenCalledTimes(1)
2497-
expect(mapStateToPropsC).toHaveBeenCalledTimes(1)
2496+
expect(mapStateToPropsB).toHaveBeenCalledOnce()
2497+
expect(mapStateToPropsC).toHaveBeenCalledOnce()
24982498
expect(mapStateToPropsD).toHaveBeenCalledTimes(2)
24992499

25002500
rtl.act(() => {
@@ -2955,7 +2955,7 @@ describe('React', () => {
29552955
</ProviderMock>,
29562956
)
29572957

2958-
expect(spy).toHaveBeenCalledTimes(1)
2958+
expect(spy).toHaveBeenCalledOnce()
29592959
expect(spy).toHaveBeenCalledWith(
29602960
'The `pure` option has been removed. `connect` is now always a "pure/memoized" component',
29612961
)

test/components/hooks.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,17 @@ describe('React', () => {
117117
)
118118

119119
// 1. Initial render
120-
expect(mapStateSpy1).toHaveBeenCalledTimes(1)
120+
expect(mapStateSpy1).toHaveBeenCalledOnce()
121121

122122
// 1.Initial render
123123
// 2. C1 useEffect
124124
expect(renderSpy1).toHaveBeenCalledTimes(2)
125125

126126
// 1. Initial render
127-
expect(mapStateSpy2).toHaveBeenCalledTimes(1)
127+
expect(mapStateSpy2).toHaveBeenCalledOnce()
128128

129129
// 1. Initial render
130-
expect(renderSpy2).toHaveBeenCalledTimes(1)
130+
expect(renderSpy2).toHaveBeenCalledOnce()
131131

132132
rtl.act(() => {
133133
store.dispatch({ type: 'FOO' })

test/hooks/useSelector.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('React', () => {
108108
)
109109

110110
expect(result).toEqual(0)
111-
expect(selector).toHaveBeenCalledTimes(1)
111+
expect(selector).toHaveBeenCalledOnce()
112112

113113
rtl.act(() => {
114114
normalStore.dispatch({ type: '' })
@@ -386,7 +386,7 @@ describe('React', () => {
386386
</ProviderMock>,
387387
)
388388

389-
expect(selector).toHaveBeenCalledTimes(1)
389+
expect(selector).toHaveBeenCalledOnce()
390390
expect(renderedItems.length).toEqual(1)
391391

392392
rtl.act(() => {
@@ -973,7 +973,7 @@ describe('React', () => {
973973
</ProviderMock>,
974974
)
975975

976-
expect(selector).toHaveBeenCalledTimes(1)
976+
expect(selector).toHaveBeenCalledOnce()
977977

978978
rtl.cleanup()
979979

@@ -988,7 +988,7 @@ describe('React', () => {
988988
</ProviderMock>,
989989
)
990990

991-
expect(selector).toHaveBeenCalledTimes(1)
991+
expect(selector).toHaveBeenCalledOnce()
992992
})
993993
it('always runs check if context or hook specifies', () => {
994994
rtl.render(

0 commit comments

Comments
 (0)