Differential D20543 Diff 61126 cashtab/src/components/Common/__tests__/cashtabAmountKeypadScroll.test.ts
Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Common/__tests__/cashtabAmountKeypadScroll.test.ts
| // Copyright (c) 2026 The Bitcoin developers | // Copyright (c) 2026 The Bitcoin developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| import { | import { | ||||
| applyAmountKeypadScrollMargin, | applyAmountKeypadScrollMargin, | ||||
| CASHTAB_AMOUNT_KEYPAD_OFFSET_PX, | CASHTAB_AMOUNT_KEYPAD_OFFSET_PX, | ||||
| CASHTAB_AMOUNT_KEYPAD_OFFSET_VAR, | CASHTAB_AMOUNT_KEYPAD_OFFSET_VAR, | ||||
| CASHTAB_AMOUNT_KEYPAD_SCROLL_PAD_PX, | CASHTAB_AMOUNT_KEYPAD_SCROLL_PAD_PX, | ||||
| CASHTAB_FIXED_CTA_ATTR, | CASHTAB_FIXED_CTA_ATTR, | ||||
| CASHTAB_FIXED_CTA_OFFSET_VAR, | CASHTAB_FIXED_CTA_OFFSET_VAR, | ||||
| CASHTAB_MOBILE_FOOTER_OFFSET_PX, | CASHTAB_MOBILE_FOOTER_OFFSET_PX, | ||||
| CASHTAB_MOBILE_FOOTER_OFFSET_VAR, | |||||
| getAmountKeypadClearancePx, | getAmountKeypadClearancePx, | ||||
| getMobileFooterOffsetPx, | getMobileFooterOffsetPx, | ||||
| measureFixedCtaOffsetPx, | measureFixedCtaOffsetPx, | ||||
| parseCssPxProperty, | parseCssPxProperty, | ||||
| scrollAmountFieldAboveKeypad, | scrollAmountFieldAboveKeypad, | ||||
| } from 'components/Common/cashtabAmountKeypadScroll'; | } from 'components/Common/cashtabAmountKeypadScroll'; | ||||
| describe('cashtabAmountKeypadScroll', () => { | describe('cashtabAmountKeypadScroll', () => { | ||||
| Show All 25 Lines | describe('getMobileFooterOffsetPx', () => { | ||||
| it('returns the Cashtab footer height on mobile', () => { | it('returns the Cashtab footer height on mobile', () => { | ||||
| const matchMedia = (() => ({ | const matchMedia = (() => ({ | ||||
| matches: false, | matches: false, | ||||
| })) as unknown as typeof window.matchMedia; | })) as unknown as typeof window.matchMedia; | ||||
| expect(getMobileFooterOffsetPx(matchMedia)).toBe( | expect(getMobileFooterOffsetPx(matchMedia)).toBe( | ||||
| CASHTAB_MOBILE_FOOTER_OFFSET_PX, | CASHTAB_MOBILE_FOOTER_OFFSET_PX, | ||||
| ); | ); | ||||
| }); | }); | ||||
| it('returns 0 on mobile when the OS keyboard offset var is 0px', () => { | |||||
| const matchMedia = (() => ({ | |||||
| matches: false, | |||||
| })) as unknown as typeof window.matchMedia; | |||||
| document.documentElement.style.setProperty( | |||||
| CASHTAB_MOBILE_FOOTER_OFFSET_VAR, | |||||
| '0px', | |||||
| ); | |||||
| try { | |||||
| expect( | |||||
| getMobileFooterOffsetPx( | |||||
| matchMedia, | |||||
| document.documentElement, | |||||
| ), | |||||
| ).toBe(0); | |||||
| } finally { | |||||
| document.documentElement.style.removeProperty( | |||||
| CASHTAB_MOBILE_FOOTER_OFFSET_VAR, | |||||
| ); | |||||
| } | |||||
| }); | |||||
| }); | }); | ||||
| describe('measureFixedCtaOffsetPx', () => { | describe('measureFixedCtaOffsetPx', () => { | ||||
| it('reads height from the marked CTA element', () => { | it('reads height from the marked CTA element', () => { | ||||
| const cta = document.createElement('div'); | const cta = document.createElement('div'); | ||||
| cta.setAttribute(CASHTAB_FIXED_CTA_ATTR, ''); | cta.setAttribute(CASHTAB_FIXED_CTA_ATTR, ''); | ||||
| Object.defineProperty(cta, 'offsetHeight', { | Object.defineProperty(cta, 'offsetHeight', { | ||||
| configurable: true, | configurable: true, | ||||
| ▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines | |||||