I have an array like this.If atleast one of the substrings within the array have the value i'm searching for it should pass.
Value1 = [
"Grape | 100 |Food Catering Service",
"Apple | 100,000m |Food Catering Service",
"Water Melon | 100,000m |Catering Service Outside",
"100,000m |Food Catering Service Outside
]
Using typescript i'm trying to make sure that atleast if a substring in the array there is the value Food. Even though the third substring within this arrat has no food it should still pass.
Code i've tried so far but does not do the job. It just returns the array
export function arraySubstring (expected:string, ignoreCase?: boolean): Expectation<string[], string> {
return Expectation.that("test", expected,
async(actor: Actor, actual: string[]): Promise<boolean> ==> {
try {
for (const value of actual) {
if(ignoreCase) {
if (!value.toLowerCase().includes(expected.toLowerCase())) return
false;
} else {
if (!value.includes(expected)) return false;
}
}
return true;
})
}
const value2= await webActor.attemptsTo(Ensure.that("my expectation",
value1, arraySubstring ("Food")))