File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 11import asyncSomeStrict from './some_strict' ;
22
33import {
4+ doubleInputArr ,
45 inputArr ,
56 largerThanTwo ,
67 largerThanTwoInRandomTime ,
78 largerThanOneHundred ,
89 largerThanOneHundredInRandomTime ,
10+ makePushDuplicate ,
11+ makePushDuplicateInRandomTime ,
912} from '../test-utils' ;
1013
1114const firstElementLargerThanTwo = inputArr . findIndex ( largerThanTwo ) ;
@@ -37,6 +40,26 @@ describe('asyncSomeStrict()', () => {
3740 } ) ;
3841 } ) ;
3942
43+ it ( 'assertions below are valid for synchronous .map()' , ( ) => {
44+ const [ arr , pushDuplicate ] = makePushDuplicate ( ) ;
45+ const mapper = jest . fn ( ) . mockImplementation ( pushDuplicate ) ;
46+
47+ inputArr . some ( mapper ) ;
48+
49+ expect ( mapper ) . toHaveBeenCalledTimes ( inputArr . length ) ;
50+ expect ( arr ) . toEqual ( doubleInputArr ) ;
51+ } ) ;
52+
53+ it ( 'iterates through an array properly with side effects' , async ( ) => {
54+ const [ arr , pushDuplicate ] = makePushDuplicateInRandomTime ( ) ;
55+ const mapper = jest . fn ( ) . mockImplementation ( pushDuplicate ) ;
56+
57+ await asyncSomeStrict ( inputArr , mapper ) ;
58+
59+ expect ( mapper ) . toHaveBeenCalledTimes ( inputArr . length ) ;
60+ expect ( arr ) . toEqual ( doubleInputArr ) ;
61+ } ) ;
62+
4063 it ( 'assertions below are valid for synchronous .some()' , ( ) => {
4164 const mapper = jest . fn ( ) . mockImplementation ( largerThanTwo ) ;
4265
You can’t perform that action at this time.
0 commit comments