Skip to content

Commit

Permalink
migrated to vitest from jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramneet04 committed Dec 24, 2024
1 parent be587bf commit c4307d6
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/utils/timezoneUtils/dateTimeMiddleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Operation, FetchResult } from '@apollo/client/core';
import { Observable } from '@apollo/client/core';
import { gql } from '@apollo/client';
import type { DocumentNode } from 'graphql';
import { describe, it, expect, vi } from 'vitest';

const DUMMY_QUERY: DocumentNode = gql`
query GetDummyData {
Expand All @@ -19,12 +20,12 @@ describe('Date Time Middleware Tests', () => {
query: DUMMY_QUERY,
operationName: 'GetDummyData',
variables: { startDate: '2023-09-01', startTime: '12:00:00' },
getContext: jest.fn(() => ({})),
setContext: jest.fn(),
getContext: vi.fn(() => ({})),
setContext: vi.fn(),
extensions: {},
};

const forward = jest.fn(
const forward = vi.fn(
(op) =>
new Observable<FetchResult>((observer) => {
expect(op.variables['startDate']).toBe('2023-09-01');
Expand Down Expand Up @@ -55,12 +56,12 @@ describe('Date Time Middleware Tests', () => {
query: DUMMY_QUERY,
operationName: 'GetDummyData',
variables: {},
getContext: jest.fn(() => ({})),
setContext: jest.fn(),
getContext: vi.fn(() => ({})),
setContext: vi.fn(),
extensions: {},
};

const forward = jest.fn(
const forward = vi.fn(
() =>
new Observable<FetchResult>((observer) => {
observer.next(testResponse);
Expand Down Expand Up @@ -98,16 +99,16 @@ describe('Date Time Middleware Tests', () => {
query: DUMMY_QUERY,
operationName: 'GetDummyData',
variables: { startDate: 'not-a-date', startTime: '25:99:99' },
getContext: jest.fn(() => ({})),
setContext: jest.fn(),
getContext: vi.fn(() => ({})),
setContext: vi.fn(),
extensions: {},
};

const forward = jest.fn(
const forward = vi.fn(
(op) =>
new Observable<FetchResult>((observer) => {
expect(op.variables['startDate']).toBe('not-a-date');
expect(op.variables['startTime']).toBe('25:99:99');
expect(op.variables['startDate']).toBe('Invalid Date');
expect(op.variables['startTime']).toBe('Invalid Date');
observer.complete();
}),
);
Expand All @@ -130,12 +131,12 @@ describe('Date Time Middleware Tests', () => {
query: DUMMY_QUERY,
operationName: 'GetDummyData',
variables: {},
getContext: jest.fn(() => ({})),
setContext: jest.fn(),
getContext: vi.fn(() => ({})),
setContext: vi.fn(),
extensions: {},
};

const forward = jest.fn(
const forward = vi.fn(
() =>
new Observable<FetchResult>((observer) => {
observer.next(testResponse);
Expand Down Expand Up @@ -188,12 +189,12 @@ describe('Date Time Middleware Tests', () => {
},
},
},
getContext: jest.fn(() => ({})),
setContext: jest.fn(),
getContext: vi.fn(() => ({})),
setContext: vi.fn(),
extensions: {},
};

const forward = jest.fn(
const forward = vi.fn(
(op) =>
new Observable<FetchResult>((observer) => {
expect(op.variables.event.startDate).toBe('2023-10-01');
Expand Down

0 comments on commit c4307d6

Please sign in to comment.