Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
sommilito-bank2
/
splide-4.1.3
/
src
/
js
/
utils
/
array
/
forEach
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
import { forEach } from './forEach'; describe( 'forEach', () => { test( 'can iterate over an array.', () => { const array = [ 1, 2, 3 ]; const callback = jest.fn(); forEach( array, ( value, index, current ) => { expect( value ).toBe( array[ index ] ); expect( current ).toBe( array ); callback(); } ); expect( callback ).toHaveBeenCalledTimes( array.length ); } ); test( 'can push the provided value to a new array and iterate over it.', () => { const callback = jest.fn(); forEach( 1, ( value, index, current ) => { expect( value ).toBe( 1 ); expect( current ).toEqual( [ 1 ] ); callback(); } ); expect( callback ).toHaveBeenCalledTimes( 1 ); } ); } );