mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-24 17:25:18 +00:00
B146 — stub innerWidth in mobile overlay unit tests
Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
23e71d2de3
commit
56e60ce589
1 changed files with 10 additions and 0 deletions
|
|
@ -54,6 +54,12 @@ const searchWithPriorityPayload: HomeSearchSuccessResponse = {
|
||||||
|
|
||||||
const matchMediaMock = vi.fn()
|
const matchMediaMock = vi.fn()
|
||||||
|
|
||||||
|
let innerWidthSpy: ReturnType<typeof vi.spyOn> | undefined
|
||||||
|
|
||||||
|
const stubMobileViewport = () => {
|
||||||
|
innerWidthSpy = vi.spyOn(window, 'innerWidth', 'get').mockReturnValue(375)
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
matchMediaMock.mockImplementation((query: string) => ({
|
matchMediaMock.mockImplementation((query: string) => ({
|
||||||
matches: false,
|
matches: false,
|
||||||
|
|
@ -69,6 +75,8 @@ beforeEach(() => {
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
cleanup()
|
cleanup()
|
||||||
|
innerWidthSpy?.mockRestore()
|
||||||
|
innerWidthSpy = undefined
|
||||||
vi.mocked(postCampaignJson).mockReset()
|
vi.mocked(postCampaignJson).mockReset()
|
||||||
vi.unstubAllGlobals()
|
vi.unstubAllGlobals()
|
||||||
})
|
})
|
||||||
|
|
@ -358,6 +366,7 @@ describe('CampaignQuickActionsOverlay (B126)', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows swipe handle and no dialog close on mobile (B146)', () => {
|
it('shows swipe handle and no dialog close on mobile (B146)', () => {
|
||||||
|
stubMobileViewport()
|
||||||
matchMediaMock.mockImplementation((query: string) => ({
|
matchMediaMock.mockImplementation((query: string) => ({
|
||||||
matches: query.includes('max-width'),
|
matches: query.includes('max-width'),
|
||||||
media: query,
|
media: query,
|
||||||
|
|
@ -393,6 +402,7 @@ describe('CampaignQuickActionsOverlay (B126)', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('uses mobile drawer with actions above search', () => {
|
it('uses mobile drawer with actions above search', () => {
|
||||||
|
stubMobileViewport()
|
||||||
matchMediaMock.mockImplementation((query: string) => ({
|
matchMediaMock.mockImplementation((query: string) => ({
|
||||||
matches: query.includes('max-width'),
|
matches: query.includes('max-width'),
|
||||||
media: query,
|
media: query,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue