I am trying to check a SubString exists in an array. In the Test i am asserting using:
expect(classList).toContain('Rail__focused')
I am getting the following error:
Error: expect(received).toContain(expected // indexOf
Expected value: "Rail__focused"
Received array: ["Rail__item__3NvGX", "Rail__focused__3bGTR", "Tile__tile__3jJYQ", "Tile__wide__1GuVb", "Tile__animated__3H87p", "Tile__active__1mtVd"]
This is what I wanted to achieve and wanted this to pass
var arr = ["Rail__item__3NvGX", "Rail__focused__3bGTR", "Tile__tile__3jJYQ", "Tile__wide__1GuVb", "Tile__animated__3H87p", "Tile__active__1mtVd"];
var str = 'Rail__focused';
for (var i = 0, len = arr.length; i < len; ++i) {
if (str.indexOf(arr[i]) != -1) {
console.log("This is a pass")
} else {
console.log("This is a fail")
}
}