import expect from '@kbn/expect' ; import { CaseResponse , CasesByAlertId } from '../../../../plugins/cases/common/api' ; /**
 * Ensure that the result of the alerts API request matches with the cases created for the test.
 */ export function validateCasesFromAlertIDResponse ( casesFromAPIResponse , createdCasesForTest ) { const idToTitle = new Map < string , string > ( createdCasesForTest . map ( ( caseInfo ) => [ caseInfo . id , caseInfo . title ] ) ) ; for ( const apiResCase of casesFromAPIResponse ) { expect ( apiResCase . title ) . to . be ( idToTitle . get ( apiResCase . id ) ) ; } } /**
 * Compares two arrays to determine if they are sort of equal. This function returns true if the arrays contain the same
 * elements but the ordering does not matter.
 */ export function arraysToEqual ( array1 ? , array2 ? ) { if ( ! array1 || ! array2 || array1 . length !== array2 . length ) { return false ; } const array1AsSet = new Set ( array1 ) ; return array2 . every ( ( item ) => array1AsSet . has ( item ) ) ; }