-
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.
feat(calendar): improve responsivity and reduce bundle size (#39)
* test(occurrence): test DayHabitModalDialog component * feat(calendar): improve responsivity * Fix tests * Rename gh workflow job * Fixes * Put back @mui/material
- Loading branch information
Showing
22 changed files
with
805 additions
and
2,536 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,7 +1,72 @@ | ||
import { useHabits, useOccurrences, useTraits } from '@context'; | ||
import { useUser } from '@supabase/auth-helpers-react'; | ||
import { render } from '@testing-library/react'; | ||
import { format } from 'date-fns'; | ||
import React from 'react'; | ||
|
||
import DayHabitModalDialog from './DayHabitModalDialog'; | ||
|
||
jest.mock('@context', () => ({ | ||
useOccurrences: jest.fn(), | ||
useHabits: jest.fn(), | ||
useTraits: jest.fn(), | ||
})); | ||
|
||
jest.mock('@supabase/auth-helpers-react', () => ({ | ||
useUser: jest.fn(), | ||
})); | ||
|
||
jest.mock('date-fns', () => ({ | ||
format: jest.fn(), | ||
})); | ||
|
||
describe(DayHabitModalDialog.name, () => { | ||
it('should be tested', () => { | ||
expect(true).toBeTruthy(); | ||
const props = { | ||
open: true, | ||
onClose: jest.fn(), | ||
date: new Date(), | ||
}; | ||
|
||
it('should render', () => { | ||
(useHabits as jest.Mock).mockReturnValue({ habits: [] }); | ||
(useUser as jest.Mock).mockReturnValue({ id: '1' }); | ||
(format as jest.Mock).mockReturnValue('2021-01-01'); | ||
(useTraits as jest.Mock).mockReturnValue({ traitsMap: {} }); | ||
(useOccurrences as jest.Mock).mockReturnValue({ | ||
addOccurrence: jest.fn(), | ||
addingOccurrence: false, | ||
}); | ||
const { getByText } = render(<DayHabitModalDialog {...props} />); | ||
expect(getByText('Add habits for 2021-01-01')).toBeInTheDocument(); | ||
expect( | ||
getByText('Select from the habits provided below') | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not render if date is null', () => { | ||
const { container } = render( | ||
<DayHabitModalDialog {...props} date={null} /> | ||
); | ||
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
it('should not render if open is false', () => { | ||
const { container } = render( | ||
<DayHabitModalDialog {...props} open={false} /> | ||
); | ||
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
it('if no habits are available, should show a message', () => { | ||
(useHabits as jest.Mock).mockReturnValue({ habits: [] }); | ||
(useUser as jest.Mock).mockReturnValue({ id: '1' }); | ||
(format as jest.Mock).mockReturnValue('2021-01-01'); | ||
(useTraits as jest.Mock).mockReturnValue({ traitsMap: {} }); | ||
(useOccurrences as jest.Mock).mockReturnValue({ | ||
addOccurrence: jest.fn(), | ||
addingOccurrence: false, | ||
}); | ||
const { getAllByText } = render(<DayHabitModalDialog {...props} />); | ||
expect(getAllByText('No habits found')).toHaveLength(2); | ||
}); | ||
}); |
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
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.