Skip to content

Commit

Permalink
refactor:vitest to Requests screen
Browse files Browse the repository at this point in the history
  • Loading branch information
shivasankaran18 committed Dec 13, 2024
1 parent ebf0d09 commit 09b4d38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Empty file modified .github/workflows/compare_translations.py
100644 → 100755
Empty file.
18 changes: 18 additions & 0 deletions src/screens/Requests/Requests.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@ import {
import useLocalStorage from 'utils/useLocalstorage';
import { vi } from 'vitest';

/**
* Unit tests for the `Requests` screen.
*
*/
/**
* Set up `localStorage` stubs for testing.
*/

vi.stubGlobal('localStorage', {
getItem: vi.fn(),
setItem: vi.fn(),
clear: vi.fn(),
removeItem: vi.fn(),
});

/**
* Mock `window.location` for testing redirection behavior.
*/
Object.defineProperty(window, 'location', {
value: { href: 'http://localhost/', assign: vi.fn(), reload: vi.fn() },
});
Expand All @@ -43,6 +54,13 @@ const link5 = new StaticMockLink(MOCKS_WITH_ERROR, true);
const link6 = new StaticMockLink(MOCKS3, true);
const link7 = new StaticMockLink(MOCKS4, true);

/**
* Utility function to wait for a specified amount of time.
* Wraps `setTimeout` in an `act` block for testing purposes.
*
* @param ms - The duration to wait in milliseconds. Default is 100ms.
* @returns A promise that resolves after the specified time.
*/
async function wait(ms = 100): Promise<void> {
await act(() => {
return new Promise((resolve) => {
Expand Down

0 comments on commit 09b4d38

Please sign in to comment.