Skip to content

Commit

Permalink
refactor:vitest to UserPortal/Organizations (#2783)
Browse files Browse the repository at this point in the history
* refactor:vitest to UserPortal/Organizations

* fix:coderabbit sugg
  • Loading branch information
shivasankaran18 authored Dec 24, 2024
1 parent 9848bae commit aff65c9
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import Organizations from './Organizations';
import React, { act } from 'react';
const { getItem } = useLocalStorage();

/**
* Mock data for GraphQL queries.
*/

const MOCKS = [
{
request: {
Expand Down Expand Up @@ -317,6 +321,10 @@ const MOCKS = [
},
];

/**
* Custom Mock Link for handling static GraphQL mocks.
*/

const link = new StaticMockLink(MOCKS, true);

async function wait(ms = 100): Promise<void> {
Expand All @@ -333,6 +341,9 @@ const resizeWindow = (width: number): void => {
};

describe('Testing Organizations Screen [User Portal]', () => {
/**
* Test to ensure the screen is rendered properly.
*/
test('Screen should be rendered properly', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -347,8 +358,13 @@ describe('Testing Organizations Screen [User Portal]', () => {
);

await wait();
expect(screen.getByText('My Organizations')).toBeInTheDocument();
});

/**
* Test to check if the search functionality works as expected.
*/

test('Search works properly', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -374,6 +390,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
await wait();
});

/**
* Test to verify the mode change to joined organizations.
*/

test('Mode is changed to joined organizations', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -397,6 +417,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
expect(screen.queryAllByText('joinedOrganization')).not.toBe([]);
});

/**
* Test case to ensure the mode can be changed to display created organizations.
*/

test('Mode is changed to created organizations', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -420,6 +444,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
expect(screen.queryAllByText('createdOrganization')).not.toBe([]);
});

/**
* Test case to check if the "Join Now" button renders correctly on the page.
*/

test('Join Now button render correctly', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down Expand Up @@ -463,6 +491,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
expect(screen.queryAllByText('createdOrganization')).not.toBe([]);
});

/**
* Test case to ensure the sidebar is functional, including opening and closing actions.
*/

test('Testing Sidebar', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down

0 comments on commit aff65c9

Please sign in to comment.