-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from RevelioStartup/staging
Deploy to PROD
- Loading branch information
Showing
59 changed files
with
4,882 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react' | ||
import { render, screen, fireEvent } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import { useGetTimelinesByEventQuery } from '@/redux/api/timelineApi' | ||
import Calendar from '@/components/elements/Timeline/Calendar' | ||
|
||
// Mock the useGetTimelinesByEventQuery hook | ||
jest.mock('@/redux/api/timelineApi', () => ({ | ||
useGetTimelinesByEventQuery: jest.fn(), | ||
})) | ||
|
||
jest.mock('@/components/elements/Timeline/Calendar', () => { | ||
return { | ||
__esModule: true, | ||
default: jest.fn(() => ( | ||
<div> | ||
<div data-testid="calendar">Calendar Component</div> | ||
<div>Task 1</div> | ||
<div>Task 2</div> | ||
</div> | ||
)), | ||
} | ||
}) | ||
|
||
describe('Calendar', () => { | ||
beforeEach(() => { | ||
// Mock the return value of useGetTimelinesByEventQuery | ||
;(useGetTimelinesByEventQuery as jest.Mock).mockReturnValue({ | ||
data: [ | ||
{ | ||
id: '1', | ||
task_step: { name: 'Task 1' }, | ||
start_datetime: new Date('2022-05-01T09:00:00Z'), | ||
end_datetime: new Date('2022-05-01T10:00:00Z'), | ||
}, | ||
{ | ||
id: '2', | ||
task_step: { name: 'Task 2' }, | ||
start_datetime: new Date('2022-05-01T11:00:00Z'), | ||
end_datetime: new Date('2022-05-01T12:00:00Z'), | ||
}, | ||
], | ||
isLoading: false, | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
test('renders the calendar component', () => { | ||
render(<Calendar eventId="123" />) | ||
expect(screen.getByTestId('calendar')).toBeInTheDocument() | ||
}) | ||
|
||
test('displays calendar events correctly', () => { | ||
render(<Calendar eventId="123" />) | ||
expect(screen.getByText('Task 1')).toBeInTheDocument() | ||
expect(screen.getByText('Task 2')).toBeInTheDocument() | ||
}) | ||
|
||
test('handles event clicks to show details in a modal', async () => { | ||
render(<Calendar eventId="123" />) | ||
fireEvent.click(screen.getByText('Task 1')) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import PackageList from '@/app/package/page' | ||
|
||
jest.mock('@/redux/api/packageApi', () => ({ | ||
useGetPackageDetailQuery: jest.fn((id) => ({ | ||
data: { | ||
name: 'Default Package', | ||
price: 5000, | ||
event_planner: true, | ||
event_tracker: true, | ||
event_timeline: true, | ||
event_rundown: true, | ||
ai_assistant: false, | ||
}, | ||
})), | ||
})) | ||
|
||
jest.mock('@/redux/api/subscriptionApi', () => ({ | ||
useGetLatestSubscriptionQuery: jest.fn((id) => ({ | ||
data: { | ||
id: 1, | ||
plan: 'PREMIUM', | ||
start_date: '2024-05-05T13:30:00.000Z', | ||
end_date: '2025-05-05T13:30:00.000Z', | ||
user: 1, | ||
is_active: false, | ||
}, | ||
})), | ||
})) | ||
|
||
describe('PackageList component', () => { | ||
it('renders correctly', () => { | ||
const { getByTestId } = render(<PackageList />) | ||
const packageDetail = getByTestId('package-detail') | ||
expect(packageDetail).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import PackageList from '@/app/package/page' | ||
|
||
jest.mock('@/redux/api/packageApi', () => ({ | ||
useGetPackageDetailQuery: jest.fn((id) => ({ | ||
data: { | ||
name: 'Default Package', | ||
price: 5000, | ||
event_planner: true, | ||
event_tracker: true, | ||
event_timeline: true, | ||
event_rundown: true, | ||
ai_assistant: false, | ||
}, | ||
})), | ||
})) | ||
|
||
jest.mock('@/redux/api/subscriptionApi', () => ({ | ||
useGetLatestSubscriptionQuery: jest.fn((id) => ({ | ||
data: { | ||
id: 1, | ||
plan: 'PREMIUM', | ||
start_date: '2024-05-05T13:30:00.000Z', | ||
end_date: '2025-05-05T13:30:00.000Z', | ||
user: 1, | ||
is_active: true, | ||
}, | ||
})), | ||
})) | ||
|
||
describe('PackageList component', () => { | ||
it('renders correctly', () => { | ||
const { getByTestId } = render(<PackageList />) | ||
const packageDetail = getByTestId('package-detail') | ||
expect(packageDetail).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.