rejectsWithError(
asyncFilter(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncFilter(array),
new TypeError('undefined is not a function')
)ranCallbacksInOrder(result)return array.every(item => {
if (item) {
return expect(filteredArray).to.contain(item);
} else {
return expect(filteredArray).to.not.contain(item);
}
});async () =>
expect(filteredArray).to.not.equal(array)ranCallbacksInOrder(result)async () => {
return array.every(item => {
if (item) {
return expect(filteredArray).to.contain(item);
} else {
return expect(filteredArray).to.not.contain(item);
}
});
}async () =>
expect(filteredArray).to.not.equal(array)async () =>
rejectsWithError(asyncFilter(array, callback), error)hasAccessToCorrectArgumentsOnCallback(array, result, [
'currentValue',
'index',
'array'
])result.every(({ thisArg }) =>
expect(thisArg.toString()).to.equal(providedThisArg.toString())
)rejectsWithError(
asyncFindIndex(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncFindIndex(array),
new TypeError('undefined is not a function')
)ranCallbacksInOrder(result)expect(foundIndex).to.equal(findIndex)expect(
typeof foundIndex === 'number' &&
foundIndex === Math.floor(foundIndex)
).to.equal(true)ranCallbacksInOrder(result)expect(foundIndex).to.equal(findIndex)expect(
typeof foundIndex === 'number' &&
foundIndex === Math.floor(foundIndex)
).to.equal(true)async () =>
rejectsWithError(asyncFindIndex(array, callback), error)hasAccessToCorrectArgumentsOnCallback(array, result, [
'currentValue',
'index',
'array'
])result.every(({ thisArg }) =>
expect(thisArg.toString()).to.equal(providedThisArg.toString())
)rejectsWithError(
asyncFind(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncFind(array),
new TypeError('undefined is not a function')
)ranCallbacksInOrder(result)expect(foundElement).to.equal(array[findIndex])ranCallbacksInOrder(result)async () => {
expect(foundElement).to.equal(array[findIndex]);
}async () =>
rejectsWithError(asyncFind(array, callback), error)hasAccessToCorrectArgumentsOnCallback(array, result, [
'currentValue',
'index',
'array'
])result.every(({ thisArg }) =>
expect(thisArg.toString()).to.equal(providedThisArg.toString())
)rejectsWithError(
asyncForEach(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncForEach(array),
new TypeError('undefined is not a function')
)ranCallbacksInOrder(result)ranCallbacksInOrder(result)async () =>
rejectsWithError(asyncForEach(array, callback), error)hasAccessToCorrectArgumentsOnCallback(array, result, [
'currentValue',
'index',
'array'
])result.every(({ thisArg }) =>
expect(thisArg.toString()).to.equal(providedThisArg.toString())
)rejectsWithError(
asyncMapSort(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncMapSort(array),
new TypeError('undefined is not a function')
)ranCallbacksInOrder(result)async () => {
expect(mapSortedArray).to.not.equal(array);
}async () => {
const expectedResult = mapSortedArray.slice().sort();
expectedResult.every((item, index) =>
expect(mapSortedArray[index]).to.equal(item)
);
}ranCallbacksInOrder(result)async () => {
expect(mapSortedArray).to.not.equal(array);
}async () => {
const expectedResult = mapSortedArray.slice().sort();
expectedResult.every((item, index) =>
expect(mapSortedArray[index]).to.equal(item)
);
}async () =>
rejectsWithError(asyncMapSort(array, mappingFunction), error)hasAccessToCorrectArgumentsOnCallback(array, result, [
'currentValue',
'index',
'array'
])result.every(({ firstEl, secondEl }) =>
expect(array)
.to.contain(firstEl)
.and.contain(secondEl)
)rejectsWithError(
asyncMap(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncMap(array),
new TypeError('undefined is not a function')
)ranCallbacksInOrder(result)async () => {
mappedArray.every((item, index) =>
expect(item).to.equal(array[index])
);
}async () => {
expect(mappedArray).to.not.equal(array);
}ranCallbacksInOrder(result)async () => {
mappedArray.every((item, index) =>
expect(item).to.equal(array[index])
);
}async () => {
expect(mappedArray).to.not.equal(array);
}async () =>
rejectsWithError(asyncMap(array, callback), error)hasAccessToCorrectArgumentsOnCallback(array, result, [
'currentValue',
'index',
'array'
])result.every(({ thisArg }) =>
expect(thisArg.toString()).to.equal(providedThisArg.toString())
)rejectsWithError(
asyncReduce(),
new TypeError('undefined is not iterable')
)rejectsWithError(
asyncReduce(array),
new TypeError('undefined is not a function')
)rejectsWithError(
asyncReduce([], () => 1),
new TypeError(
'asyncReduce of empty array with no accumulator given'
)
)ranCallbacksInOrder(result, { skipFirst: false });
expect(result.length).to.be.greaterThan(
0,
'No callbacks were run.'
);async () => {
array.every((element, index) => {
return expect(reducedAccumulator[index].item).to.equal(element);
});
}async () => {
result.every(({ item }, index) => {
return expect(reducedAccumulator[index].item).to.equal(item);
});
expect(result.length).to.be.greaterThan(
0,
'No callbacks were run.'
);
}ranCallbacksInOrder(result, { skipFirst: false });
expect(result.length).to.be.greaterThan(
0,
'No callbacks were run.'
);async () => {
array.every((element, index) => {
return expect(reducedAccumulator[index].item).to.equal(element);
});
}async () => {
result.every(({ item }, index) => {
return expect(reducedAccumulator[index].item).to.equal(item);
});
expect(result.length).to.be.greaterThan(
0,
'No callbacks were run.'
);
}async () =>
rejectsWithError(asyncReduce(array, callback), error)hasAccessToCorrectArgumentsOnCallback(
array,
result,
['accumulator', 'currentValue', 'index', 'array'],
{ skipFirst: true }
);
expect(result.length).to.be.greaterThan(
0,
'No callbacks were run.'
);expect(
result.every(
({ accumulator: resultAccumulator }) =>
resultAccumulator === accumulator
)
).to.be.true;
expect(result.length).to.be.greaterThan(
0,
'No callbacks were run.'
);rejectsWithError(
asyncSort(),
new TypeError('undefined is not iterable')
)const expectedResult = array.slice().sort();
expectedResult.every((item, index) =>
expect(item).to.equal(sortedArray[index])
);async () => {
sortedArray.every((item, index) =>
expect(item).to.equal(array[index])
);
}async () =>
expect(sortedArray).to.equal(array)async () => {
sortedArray.every((item, index) =>
expect(item).to.equal(array[index])
);
}async () =>
expect(sortedArray).to.equal(array)async () =>
rejectsWithError(asyncSort(array, compareFunc), error)result.every(({ firstEl, secondEl }) =>
expect(array)
.to.contain(firstEl)
.and.contain(secondEl)
)expect(moduleImport.asyncFilter).to.be.a('function');expect(moduleImport.asyncFindIndex).to.be.a('function');expect(moduleImport.asyncFind).to.be.a('function');expect(moduleImport.asyncForEach).to.be.a('function');expect(moduleImport.asyncMapSort).to.be.a('function');expect(moduleImport.asyncMap).to.be.a('function');expect(moduleImport.asyncReduce).to.be.a('function');expect(moduleImport.asyncSort).to.be.a('function');