Skip to content

Commit

Permalink
increased coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulch07 committed Feb 1, 2025
1 parent bdab69f commit dd3b29d
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

# Variable: MOCKS

> `const` **MOCKS**: (\{ `request`: \{ `notifyOnNetworkStatusChange`: `boolean`; `query`: `DocumentNode`; `variables`: \{ `address`: `undefined`; `description`: `undefined`; `filter`: `string`; `first`: `number`; `image`: `undefined`; `name`: `undefined`; `orderBy`: `string`; `skip`: `number`; `userId`: `undefined`; `userRegistrationRequired`: `undefined`; `visibleInSearch`: `undefined`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: `undefined`; `organizationsConnection`: [`InterfaceOrgInfoTypePG`](../../../../utils/interfaces/interfaces/InterfaceOrgInfoTypePG.md)[]; `user`: `undefined`; \}; \}; \} \| \{ `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: \{ `address`: `undefined`; `description`: `undefined`; `filter`: `undefined`; `first`: `undefined`; `image`: `undefined`; `name`: `undefined`; `orderBy`: `undefined`; `skip`: `undefined`; `userId`: `string`; `userRegistrationRequired`: `undefined`; `visibleInSearch`: `undefined`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: `undefined`; `organizationsConnection`: `undefined`; `user`: [`InterfaceUserType`](../../../../utils/interfaces/interfaces/InterfaceUserType.md); \}; \}; \} \| \{ `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: `undefined`; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: \{ `id`: `string`; `name`: `string`; \}; `organizationsConnection`: `undefined`; `user`: `undefined`; \}; \}; \} \| \{ `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: \{ `address`: \{ `city`: `string`; `countryCode`: `string`; `dependentLocality`: `string`; `line1`: `string`; `line2`: `string`; `postalCode`: `string`; `sortingCode`: `string`; `state`: `string`; \}; `description`: `string`; `filter`: `undefined`; `first`: `undefined`; `image`: `string`; `name`: `string`; `orderBy`: `undefined`; `skip`: `undefined`; `userId`: `undefined`; `userRegistrationRequired`: `boolean`; `visibleInSearch`: `boolean`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: \{ `_id`: `string`; \}; `createSampleOrganization`: `undefined`; `organizationsConnection`: `undefined`; `user`: `undefined`; \}; \}; \})[]
> `const` **MOCKS**: (\{ `request`: \{ `query`: `DocumentNode`; `variables`: \{ `address`: `undefined`; `description`: `undefined`; `first`: `undefined`; `id`: `undefined`; `image`: `undefined`; `name`: `undefined`; `userId`: `string`; `userRegistrationRequired`: `undefined`; `visibleInSearch`: `undefined`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: `undefined`; `user`: [`InterfaceUserType`](../../../../utils/interfaces/interfaces/InterfaceUserType.md); \}; \}; \} \| \{ `request`: \{ `query`: `DocumentNode`; `variables`: `undefined`; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: \{ `id`: `string`; `name`: `string`; \}; `user`: `undefined`; \}; \}; \} \| \{ `request`: \{ `query`: `DocumentNode`; `variables`: \{ `address`: \{ `city`: `string`; `countryCode`: `string`; `dependentLocality`: `string`; `line1`: `string`; `line2`: `string`; `postalCode`: `string`; `sortingCode`: `string`; `state`: `string`; \}; `description`: `string`; `first`: `undefined`; `id`: `undefined`; `image`: `string`; `name`: `string`; `userId`: `undefined`; `userRegistrationRequired`: `boolean`; `visibleInSearch`: `boolean`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: \{ `_id`: `string`; \}; `createSampleOrganization`: `undefined`; `user`: `undefined`; \}; \}; \} \| \{ `request`: \{ `query`: `DocumentNode`; `variables`: \{ `address`: `undefined`; `description`: `undefined`; `first`: `number`; `id`: `string`; `image`: `undefined`; `name`: `undefined`; `userId`: `undefined`; `userRegistrationRequired`: `undefined`; `visibleInSearch`: `undefined`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: `undefined`; `user`: \{ `organizationsWhereMember`: \{ `edges`: `object`[]; `pageInfo`: \{ `hasNextPage`: `boolean`; \}; \}; \}; \}; \}; \} \| \{ `request`: \{ `query`: `DocumentNode`; `variables`: \{ `address`: `undefined`; `description`: `undefined`; `first`: `number`; `id`: `string`; `image`: `undefined`; `name`: `undefined`; `userId`: `undefined`; `userRegistrationRequired`: `undefined`; `visibleInSearch`: `undefined`; \}; \}; `result`: \{ `data`: \{ `createOrganization`: `undefined`; `createSampleOrganization`: `undefined`; `user`: \{ `organizationsWhereMember`: \{ `edges`: `object`[]; `pageInfo`: `undefined`; \}; \}; \}; \}; \})[]

Defined in: [src/screens/OrgList/OrgListMocks.ts:79](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L79)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

> `const` **MOCKS\_ADMIN**: (\{ `request`: \{ `notifyOnNetworkStatusChange`: `boolean`; `query`: `DocumentNode`; `variables`: \{ `filter`: `string`; `first`: `number`; `orderBy`: `string`; `skip`: `number`; `userId`: `undefined`; \}; \}; `result`: \{ `data`: \{ `organizationsConnection`: [`InterfaceOrgInfoTypePG`](../../../../utils/interfaces/interfaces/InterfaceOrgInfoTypePG.md)[]; `user`: `undefined`; \}; \}; \} \| \{ `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: \{ `filter`: `undefined`; `first`: `undefined`; `orderBy`: `undefined`; `skip`: `undefined`; `userId`: `string`; \}; \}; `result`: \{ `data`: \{ `organizationsConnection`: `undefined`; `user`: [`InterfaceUserType`](../../../../utils/interfaces/interfaces/InterfaceUserType.md); \}; \}; \})[]
Defined in: [src/screens/OrgList/OrgListMocks.ts:213](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L213)
Defined in: [src/screens/OrgList/OrgListMocks.ts:283](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L283)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

> `const` **MOCKS\_EMPTY**: (\{ `request`: \{ `notifyOnNetworkStatusChange`: `boolean`; `query`: `DocumentNode`; `variables`: \{ `filter`: `string`; `first`: `number`; `orderBy`: `string`; `skip`: `number`; `userId`: `undefined`; \}; \}; `result`: \{ `data`: \{ `organizationsConnection`: `any`[]; `user`: `undefined`; \}; \}; \} \| \{ `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: \{ `filter`: `undefined`; `first`: `undefined`; `orderBy`: `undefined`; `skip`: `undefined`; `userId`: `string`; \}; \}; `result`: \{ `data`: \{ `organizationsConnection`: `undefined`; `user`: [`InterfaceUserType`](../../../../utils/interfaces/interfaces/InterfaceUserType.md); \}; \}; \})[]
Defined in: [src/screens/OrgList/OrgListMocks.ts:149](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L149)
Defined in: [src/screens/OrgList/OrgListMocks.ts:219](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L219)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

> `const` **MOCKS\_WITH\_ERROR**: (\{ `error`: `undefined`; `request`: \{ `notifyOnNetworkStatusChange`: `boolean`; `query`: `DocumentNode`; `variables`: \{ `filter`: `string`; `first`: `number`; `orderBy`: `string`; `skip`: `number`; `userId`: `undefined`; \}; \}; `result`: \{ `data`: \{ `organizationsConnection`: [`InterfaceOrgInfoTypePG`](../../../../utils/interfaces/interfaces/InterfaceOrgInfoTypePG.md)[]; `user`: `undefined`; \}; \}; \} \| \{ `error`: `undefined`; `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: \{ `filter`: `undefined`; `first`: `undefined`; `orderBy`: `undefined`; `skip`: `undefined`; `userId`: `string`; \}; \}; `result`: \{ `data`: \{ `organizationsConnection`: `undefined`; `user`: [`InterfaceUserType`](../../../../utils/interfaces/interfaces/InterfaceUserType.md); \}; \}; \} \| \{ `error`: `Error`; `request`: \{ `notifyOnNetworkStatusChange`: `undefined`; `query`: `DocumentNode`; `variables`: `undefined`; \}; `result`: `undefined`; \})[]

Defined in: [src/screens/OrgList/OrgListMocks.ts:177](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L177)
Defined in: [src/screens/OrgList/OrgListMocks.ts:247](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/screens/OrgList/OrgListMocks.ts#L247)
27 changes: 27 additions & 0 deletions src/screens/OrgList/OrgList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,33 @@ describe('Organisations Page testing as SuperAdmin', () => {
await wait();
});

test('testing scroll', async () => {
setItem('id', '123');

render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<OrgList />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

await waitFor(() => {
expect(screen.queryByText(/Create Organization/i)).toBeNull();
});

// Wait for initial organizations to load
expect(await screen.findByText('Organization 1')).toBeInTheDocument();
expect(await screen.findByText('Organization 2')).toBeInTheDocument();

// Simulate infinite scroll trigger (fetchMore)
fireEvent.scroll(window, { target: { scrollY: 2000 } });
});

// test('Testing create organization modal', async () => {
// setItem('id', '123');
// setItem('SuperAdmin', true);
Expand Down
104 changes: 87 additions & 17 deletions src/screens/OrgList/OrgListMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,6 @@ const organizations: InterfaceOrgInfoTypePG[] = [

// MOCKS FOR SUPERADMIN
const MOCKS = [
{
request: {
query: USER_JOINED_ORGANIZATIONS_PG,
variables: {
first: 8,
skip: 0,
filter: '',
orderBy: 'createdAt_ASC',
},
notifyOnNetworkStatusChange: true,
},
result: {
data: {
organizationsConnection: organizations,
},
},
},
{
request: {
query: CURRENT_USER,
Expand Down Expand Up @@ -145,6 +128,93 @@ const MOCKS = [
},
},
},
{
request: {
query: USER_JOINED_ORGANIZATIONS_PG,
variables: {
id: '123',
first: 8,
},
},
result: {
data: {
user: {
organizationsWhereMember: {
pageInfo: {
hasNextPage: true,
},
edges: [
{
node: {
id: 'org1',
name: 'Organization 1',
avatarURL: 'image1.jpg',
addressLine1: 'Address 1',
description: 'Description 1',
members: {
edges: [
{
node: {
id: 'abc',
},
},
],
},
},
},
{
node: {
id: 'org2',
name: 'Organization 2',
avatarURL: 'image2.jpg',
addressLine1: 'Address 2',
description: 'Description 2',
members: {
edges: [
{
node: {
id: 'def',
},
},
],
},
},
},
],
},
},
},
},
},
{
request: {
query: USER_JOINED_ORGANIZATIONS_PG,
variables: {
id: '123',
first: 8,
},
},
result: {
data: {
user: {
organizationsWhereMember: {
edges: [
{
node: {
id: 'org3',
name: 'Organization 3',
image: 'image3.jpg',
address: 'Address 3',
members: [{ id: 'm3' }],
admins: [{ id: 'a3' }],
},
},
],
},
},
},
},
},
];
const MOCKS_EMPTY = [
{
Expand Down

0 comments on commit dd3b29d

Please sign in to comment.