import { matcherErrorMessage } from 'jest-matcher-utils' ; /**
 * Expect array to be filled with value, and optionally length
 */ function toEqualArrayOf ( this , received , value , length ? ) { const matcherName = 'toEqualArrayOf' ; if ( ! Array . isArray ( received ) ) { throw new TypeError ( matcherErrorMessage ( this . utils . matcherHint ( matcherName ) , `${ this . utils . RECEIVED_COLOR ( 'received' ) } value must be an array.` , `Received type: ${ typeof received }` ) ) ; } const receivedPretty = this . utils . printReceived ( received ) ; const elementCheck = received . every ( ( v ) => v === value ) ; const lengthCheck = length === undefined || received . length === length ; if ( ! lengthCheck ) { return { pass : false , message : ( ) => `expected array length to be ${ length } but got ${ received . length }` , } ; } if ( ! elementCheck ) { return { pass : false , message : ( ) => `expected ${ receivedPretty } to be an array of ${ value }'s` , } ; } return { pass : true , message : ( ) => `expected ${ receivedPretty } not to be an array of ${ value }'s` , } ; } expect . extend ( { toEqualArrayOf , } ) ;