Skip to content

Commit bab2e8b

Browse files
author
sunjieming
committed
Fix array test
1 parent e98b5db commit bab2e8b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/arrays.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ describe('arrays', () => {
2828
it('should pass each item into the transform function', () => {
2929
const arr = [1, 2, 3];
3030
const mappedArr = arrayMethods.map(arr, n => (n * 2));
31-
expect(mappedArr[0]).toBe(2);
32-
expect(mappedArr[1]).toBe(4);
33-
expect(mappedArr[2]).toBe(6);
31+
console.log('>>>mappedArr', mappedArr);
32+
expect(mappedArr).toEqual([2, 4, 6]);
3433
});
3534
});
3635

@@ -45,6 +44,11 @@ describe('arrays', () => {
4544
const result = arrayMethods.reduce(arr, (memo, num) => (memo + num), 10);
4645
expect(result).toBe(25);
4746
});
47+
it('should handle any type of data in the array', () => {
48+
const arr = ['h', 'e', 'l', 'l', 'o', '!'];
49+
const result = arrayMethods.reduce(arr, (memo, num) => (memo + num));
50+
expect(result).toBe('hello!');
51+
});
4852
});
4953

5054
describe('find', () => {

0 commit comments

Comments
 (0)