diff --git a/src/__tests__/useGetSetState.test.ts b/src/__tests__/useGetSetState.test.ts index e9eb6aef..46a27fbf 100644 --- a/src/__tests__/useGetSetState.test.ts +++ b/src/__tests__/useGetSetState.test.ts @@ -100,8 +100,7 @@ it('should log an error if set with a patch different than an object', () => { const [, set] = result.current; expect(mockConsoleError).not.toHaveBeenCalled(); - // @ts-ignore - act(() => set('not an object')); + act(() => set('not an object' as any)); expect(mockConsoleError).toHaveBeenCalledTimes(1); expect(mockConsoleError).toHaveBeenCalledWith('useGetSetState setter patch must be an object.'); diff --git a/src/__tests__/useMap.test.ts b/src/__tests__/useMap.test.ts index 242df55f..cc9d57a8 100644 --- a/src/__tests__/useMap.test.ts +++ b/src/__tests__/useMap.test.ts @@ -1,7 +1,7 @@ import { act, renderHook } from '@testing-library/react-hooks'; import useMap from '../useMap'; -const setUp = (initialMap?: object) => renderHook(() => useMap(initialMap)); +const setUp = (initialMap?: T) => renderHook(() => useMap(initialMap)); it('should init map and utils', () => { const { result } = setUp({ foo: 'bar', a: 1 }); @@ -28,7 +28,6 @@ it('should get corresponding value for existing provided key', () => { let value; act(() => { - // @ts-ignore value = utils.get('a'); }); @@ -36,12 +35,11 @@ it('should get corresponding value for existing provided key', () => { }); it('should get undefined for non-existing provided key', () => { - const { result } = setUp({ foo: 'bar', a: 1 }); + const { result } = setUp<{ foo: string; a: number; nonExisting?: any }>({ foo: 'bar', a: 1 }); const [, utils] = result.current; let value; act(() => { - // @ts-ignore value = utils.get('nonExisting'); }); @@ -49,11 +47,10 @@ it('should get undefined for non-existing provided key', () => { }); it('should set new key-value pair', () => { - const { result } = setUp({ foo: 'bar', a: 1 }); + const { result } = setUp<{ foo: string; a: number; newKey?: number }>({ foo: 'bar', a: 1 }); const [, utils] = result.current; act(() => { - // @ts-ignore utils.set('newKey', 99); }); @@ -65,11 +62,10 @@ it('should override current value if setting existing key', () => { const [, utils] = result.current; act(() => { - // @ts-ignore - utils.set('foo', 99); + utils.set('foo', 'qux'); }); - expect(result.current[0]).toEqual({ foo: 99, a: 1 }); + expect(result.current[0]).toEqual({ foo: 'qux', a: 1 }); }); it('should remove corresponding key-value pair for existing provided key', () => { @@ -77,7 +73,6 @@ it('should remove corresponding key-value pair for existing provided key', () => const [, utils] = result.current; act(() => { - // @ts-ignore utils.remove('foo'); }); @@ -85,11 +80,10 @@ it('should remove corresponding key-value pair for existing provided key', () => }); it('should do nothing if removing non-existing provided key', () => { - const { result } = setUp({ foo: 'bar', a: 1 }); + const { result } = setUp<{ foo: string; a: number; nonExisting?: any }>({ foo: 'bar', a: 1 }); const [, utils] = result.current; act(() => { - // @ts-ignore utils.remove('nonExisting'); }); @@ -97,11 +91,10 @@ it('should do nothing if removing non-existing provided key', () => { }); it('should reset map to initial object provided', () => { - const { result } = setUp({ foo: 'bar', a: 1 }); + const { result } = setUp<{ foo: string; a: number; z?: number }>({ foo: 'bar', a: 1 }); const [, utils] = result.current; act(() => { - // @ts-ignore utils.set('z', 99); });