-
Notifications
You must be signed in to change notification settings - Fork 220
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 #9123 from weseek/fix/114434-153937-pagelistmodal-…
…navtab fix: Make CustomNavTab responsive
- Loading branch information
Showing
6 changed files
with
126 additions
and
15 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
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 |
---|---|---|
|
@@ -14,5 +14,4 @@ | |
border-bottom: 3px solid; | ||
transition: 0.3s ease-in-out; | ||
} | ||
|
||
} |
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
70 changes: 70 additions & 0 deletions
70
apps/app/src/client/components/DescendantsPageListModal.spec.tsx
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,70 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
|
||
import { DescendantsPageListModal } from './DescendantsPageListModal'; | ||
|
||
const mockClose = vi.hoisted(() => vi.fn()); | ||
const useIsDeviceLargerThanLg = vi.hoisted(() => vi.fn().mockReturnValue({ data: true })); | ||
|
||
vi.mock('next/router', () => ({ | ||
useRouter: () => ({ | ||
events: { | ||
on: vi.fn(), | ||
off: vi.fn(), | ||
}, | ||
}), | ||
})); | ||
|
||
vi.mock('~/stores/modal', () => ({ | ||
useDescendantsPageListModal: vi.fn().mockReturnValue({ | ||
data: { isOpened: true }, | ||
close: mockClose, | ||
}), | ||
})); | ||
|
||
vi.mock('~/stores/ui', () => ({ | ||
useIsDeviceLargerThanLg, | ||
})); | ||
|
||
describe('DescendantsPageListModal.tsx', () => { | ||
|
||
it('should render the modal when isOpened is true', () => { | ||
render(<DescendantsPageListModal />); | ||
expect(screen.getByTestId('descendants-page-list-modal')).not.toBeNull(); | ||
}); | ||
|
||
it('should call close function when close button is clicked', () => { | ||
render(<DescendantsPageListModal />); | ||
const closeButton = screen.getByLabelText('Close'); | ||
fireEvent.click(closeButton); | ||
expect(mockClose).toHaveBeenCalled(); | ||
}); | ||
|
||
describe('when device is larger than lg', () => { | ||
|
||
it('should render CustomNavTab', () => { | ||
render(<DescendantsPageListModal />); | ||
expect(screen.getByTestId('custom-nav-tab')).not.toBeNull(); | ||
}); | ||
|
||
it('should not render CustomNavDropdown', () => { | ||
render(<DescendantsPageListModal />); | ||
expect(screen.queryByTestId('custom-nav-dropdown')).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('when device is smaller than lg', () => { | ||
beforeEach(() => { | ||
useIsDeviceLargerThanLg.mockReturnValue({ data: false }); | ||
}); | ||
|
||
it('should render CustomNavDropdown on devices smaller than lg', () => { | ||
render(<DescendantsPageListModal />); | ||
expect(screen.getByTestId('custom-nav-dropdown')).not.toBeNull(); | ||
}); | ||
|
||
it('should not render CustomNavTab', () => { | ||
render(<DescendantsPageListModal />); | ||
expect(screen.queryByTestId('custom-nav-tab')).toBeNull(); | ||
}); | ||
}); | ||
}); |
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