Skip to content

Commit

Permalink
Enable lint for tests and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
asimonok committed Nov 23, 2023
1 parent ba4fa06 commit 549da7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ websocket/
timescale/

# Tests
**/*.test.ts
**/*.test.tsx
__mocks__
10 changes: 9 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
"ecmaVersion": "latest",
"project": "./tsconfig.json",
"sourceType": "module"
}
},
"overrides": [
{
"files": ["**/*.test.tsx", "**/*.test.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}
12 changes: 6 additions & 6 deletions src/hooks/useFavorites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('Use Favorites', () => {
* Render Hook without errors
* @param hook
*/
const renderHookWithoutErrors = async <T>(hook: () => T): Promise<RenderHookResult<T, {}>> => {
const result = await renderHook(() => hook());
const renderHookWithoutErrors = async <T>(hook: () => T): Promise<RenderHookResult<T, null>> => {
const result = await act(async () => renderHook(() => hook()));

await new Promise((resolve) => setTimeout(resolve));
return result;
Expand All @@ -34,7 +34,7 @@ describe('Use Favorites', () => {
})
);

const { result } = await act(() => renderHookWithoutErrors(() => useFavorites()));
const { result } = await renderHookWithoutErrors(() => useFavorites());

await waitFor(() => expect(result.current.isAdded('device', 'device1')).toBeTruthy());
await waitFor(() => expect(result.current.isAdded('country', 'USA')).not.toBeTruthy());
Expand All @@ -44,7 +44,7 @@ describe('Use Favorites', () => {
it('Should work without initial data', async () => {
jest.mocked(window.localStorage.getItem).mockImplementation(() => null);

const { result } = await act(() => renderHookWithoutErrors(() => useFavorites()));
const { result } = await renderHookWithoutErrors(() => useFavorites());

await waitFor(() => expect(result.current.isAdded('device', 'device1')).not.toBeTruthy());
});
Expand All @@ -56,7 +56,7 @@ describe('Use Favorites', () => {
})
);

const { result } = await act(() => renderHookWithoutErrors(() => useFavorites()));
const { result } = await renderHookWithoutErrors(() => useFavorites());

/**
* Add to already existing list
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Use Favorites', () => {
})
);

const { result } = await act(() => renderHookWithoutErrors(() => useFavorites()));
const { result } = await renderHookWithoutErrors(() => useFavorites());

/**
* Remove from already existing list
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Use Status', () => {
{
name: 'last',
values: [70, 81],
display: (value: number) => ({}),
display: () => ({}),
},
],
}),
Expand Down

0 comments on commit 549da7d

Please sign in to comment.