1 import updateItem from './updateItem';
3 describe('updateItem()', () => {
4 it('returns empty array if array is empty', () => {
5 const array: any[] = [];
7 const newItem = 'new item';
9 const result = updateItem(array, index, newItem);
11 expect(result).toStrictEqual([]);
14 it('updates correct item', () => {
15 const array = ['item 0', 'item 1', 'item 2'];
17 const newItem = 'new item';
19 const result = updateItem(array, index, newItem);
21 expect(result).toStrictEqual(['item 0', 'new item', 'item 2']);
24 it('does not update array if index does not exist', () => {
25 const array = ['item 0', 'item 1', 'item 2'];
27 const newItem = 'new item';
29 const result = updateItem(array, index, newItem);
31 expect(result).toStrictEqual(array);