Skip to content

Commit

Permalink
Refactored & removed instances of jest in scripts (#3526)
Browse files Browse the repository at this point in the history
* refactored & removed instances of jest in scripts

* updates vi configurations in setupTests.ts

* resolved coderabbit conversation
  • Loading branch information
syedali237 authored Feb 2, 2025
1 parent 735869e commit 1183dfc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 39 deletions.
25 changes: 1 addition & 24 deletions docs/docs/auto-docs/screens/OrgList/OrgList/functions/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,7 @@

> **default**(): `JSX.Element`
Defined in: [src/screens/OrgList/OrgList.tsx:56](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgList.tsx#L56)

## CSS Strategy Explanation:

To ensure consistency across the application and reduce duplication, common styles
(such as button styles) have been moved to the global CSS file. Instead of using
component-specific classes (e.g., `.greenregbtnOrganizationFundCampaign`, `.greenregbtnPledge`), a single reusable
class (e.g., .addButton) is now applied.

### Benefits:
- **Reduces redundant CSS code.
- **Improves maintainability by centralizing common styles.
- **Ensures consistent styling across components.

### Global CSS Classes used:
- `.inputField`
- `.searchButton`
- `.btnsContainer`
- `.input`
- `.btnsBlock`
- `.dropdown`
- `.modalHeader`

For more details on the reusable classes, refer to the global CSS file.
Defined in: [src/screens/OrgList/OrgList.tsx:68](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgList.tsx#L68)

## Returns

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

> **default**(`props`, `deprecatedLegacyContext`?): `ReactNode`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:64](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L64)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:65](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L65)

Represents the organization modal component.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Interface: InterfaceOrganizationModalProps

Defined in: [src/screens/OrgList/OrganizationModal.tsx:49](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L49)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:50](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L50)

Represents the properties of the OrganizationModal component.

Expand All @@ -14,7 +14,7 @@ Represents the properties of the OrganizationModal component.

> **createOrg**: (`e`) => `Promise`\<`void`\>
Defined in: [src/screens/OrgList/OrganizationModal.tsx:54](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L54)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:55](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L55)

#### Parameters

Expand All @@ -32,15 +32,15 @@ Defined in: [src/screens/OrgList/OrganizationModal.tsx:54](https://github.com/Pa

> **formState**: `InterfaceFormStateType`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:52](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L52)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:53](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L53)

***

### setFormState()

> **setFormState**: (`state`) => `void`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:53](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L53)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:54](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L54)

#### Parameters

Expand All @@ -58,15 +58,15 @@ Defined in: [src/screens/OrgList/OrganizationModal.tsx:53](https://github.com/Pa

> **showModal**: `boolean`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:50](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L50)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:51](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L51)

***

### t()

> **t**: (`key`) => `string`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:55](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L55)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:56](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L56)

#### Parameters

Expand All @@ -84,7 +84,7 @@ Defined in: [src/screens/OrgList/OrganizationModal.tsx:55](https://github.com/Pa

> **tCommon**: (`key`) => `string`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:56](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L56)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:57](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L57)

#### Parameters

Expand All @@ -102,7 +102,7 @@ Defined in: [src/screens/OrgList/OrganizationModal.tsx:56](https://github.com/Pa

> **toggleModal**: () => `void`
Defined in: [src/screens/OrgList/OrganizationModal.tsx:51](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L51)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:52](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L52)

#### Returns

Expand All @@ -114,4 +114,4 @@ Defined in: [src/screens/OrgList/OrganizationModal.tsx:51](https://github.com/Pa

> **userData**: [`InterfaceCurrentUserTypePG`](../../../../utils/interfaces/interfaces/InterfaceCurrentUserTypePG.md)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:57](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L57)
Defined in: [src/screens/OrgList/OrganizationModal.tsx:58](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrganizationModal.tsx#L58)
4 changes: 3 additions & 1 deletion scripts/__mocks__/@dicebear/collection.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const initials = jest.fn();
import { vi } from 'vitest';

export const initials = vi.fn();
6 changes: 4 additions & 2 deletions scripts/__mocks__/@dicebear/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const createAvatar = jest.fn(() => {
import { vi } from 'vitest';

export const createAvatar = vi.fn(() => {
return {
toDataUri: jest.fn(() => 'mocked-data-uri'),
toDataUri: vi.fn(() => 'mocked-data-uri'),
};
});
File renamed without changes.
6 changes: 4 additions & 2 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
global.fetch = jest.fn();
import { vi } from 'vitest';
global.fetch = vi.fn();

import { format } from 'util';

Expand Down Expand Up @@ -31,4 +32,5 @@ jestPreviewConfigure({
autoPreview: true,
});

jest.setTimeout(18000);
vi.useFakeTimers();
vi.advanceTimersByTime(18000);

0 comments on commit 1183dfc

Please sign in to comment.