Add useList additional test

This commit is contained in:
Mario Beltrán Alarcón 2019-07-31 00:15:19 +02:00
parent 85f5d26158
commit 93e76dc48f

View File

@ -1,7 +1,7 @@
import { act, renderHook } from '@testing-library/react-hooks';
import useList from '../useList';
const setUp = (initialList: any[]) => renderHook(() => useList(initialList));
const setUp = (initialList?: any[]) => renderHook(() => useList(initialList));
it('should init list and utils', () => {
const { result } = setUp([1, 2, 3]);
@ -19,6 +19,12 @@ it('should init list and utils', () => {
});
});
it('should init empty list if not initial list provided', () => {
const { result } = setUp();
expect(result.current[0]).toEqual([]);
});
it('should set new list', () => {
const initList = [1, 2, 3];
const { result } = setUp(initList);