Skip to content

Commit

Permalink
Merge branch 'develop-postgres' into issue-2562
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 authored Dec 19, 2024
2 parents f804edf + 4f05052 commit d752471
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import MemberDetail, { getLanguageName, prettyDate } from './MemberDetail';
import { MOCKS1, MOCKS2, MOCKS3 } from './MemberDetailMocks';
import type { ApolloLink } from '@apollo/client';
import { toast } from 'react-toastify';
import { vi } from 'vitest';

const link1 = new StaticMockLink(MOCKS1, true);
const link2 = new StaticMockLink(MOCKS2, true);
Expand All @@ -44,21 +45,28 @@ const translations = {
),
};

jest.mock('@mui/x-date-pickers/DateTimePicker', () => {
vi.mock('@mui/x-date-pickers/DateTimePicker', async () => {
const actual = await vi.importActual(
'@mui/x-date-pickers/DesktopDateTimePicker',
);
return {
DateTimePicker: jest.requireActual(
'@mui/x-date-pickers/DesktopDateTimePicker',
).DesktopDateTimePicker,
DateTimePicker: actual.DesktopDateTimePicker,
};
});

jest.mock('react-toastify', () => ({
vi.mock('react-toastify', () => ({
toast: {
success: jest.fn(),
error: jest.fn(),
success: vi.fn(),
error: vi.fn(),
},
}));

vi.mock('@dicebear/core', () => ({
createAvatar: vi.fn(() => ({
toDataUri: vi.fn(() => 'mocked-data-uri'),
})),
}));

const props = {
id: 'rishav-jha-mech',
};
Expand Down Expand Up @@ -87,10 +95,10 @@ const renderMemberDetailScreen = (link: ApolloLink): RenderResult => {
};

describe('MemberDetail', () => {
global.alert = jest.fn();
global.alert = vi.fn();

afterEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
cleanup();
});

Expand All @@ -115,7 +123,7 @@ describe('MemberDetail', () => {

test('prettyDate function should work properly', () => {
// If the date is provided
const datePretty = jest.fn(prettyDate);
const datePretty = vi.fn(prettyDate);
expect(datePretty('2023-02-18T09:22:27.969Z')).toBe(
prettyDate('2023-02-18T09:22:27.969Z'),
);
Expand All @@ -124,7 +132,7 @@ describe('MemberDetail', () => {
});

test('getLanguageName function should work properly', () => {
const getLangName = jest.fn(getLanguageName);
const getLangName = vi.fn(getLanguageName);
// If the language code is provided
expect(getLangName('en')).toBe('English');
// If the language code is not provided
Expand Down Expand Up @@ -229,7 +237,7 @@ describe('MemberDetail', () => {

expect(screen.queryByText('Loading data...')).not.toBeInTheDocument();

const dicebearUrl = `mocked-data-uri`;
const dicebearUrl = 'mocked-data-uri';

const userImage = await screen.findByTestId('userImageAbsent');
expect(userImage).toBeInTheDocument();
Expand Down

0 comments on commit d752471

Please sign in to comment.