Skip to content

Commit b7cd8e4

Browse files
author
sukyeong
committed
fix: add restoreAllMocks in test code
1 parent 2d4a7b4 commit b7cd8e4

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

packages/mobile/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// Utils
22
export { isServer } from './utils/isServer.ts';
3+
export { getKeyboardHeight } from './utils/keyboardHeight/getKeyboardHeight.ts';

packages/mobile/src/utils/keyboardHeight/getKeyboardHeight.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('getKeyboardHeight', () => {
66
const originalVisualViewport = window.visualViewport;
77

88
afterEach(() => {
9+
vi.restoreAllMocks();
910
Object.defineProperty(window, 'visualViewport', {
1011
value: originalVisualViewport,
1112
writable: true,

packages/mobile/src/utils/keyboardHeight/getKeyboardHeight.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { isServer } from '../isServer.ts';
2+
13
/**
24
* Returns the current on-screen keyboard height in pixels.
35
*
@@ -24,6 +26,10 @@
2426
* ```
2527
*/
2628
export function getKeyboardHeight(): number {
29+
if (isServer()) {
30+
return 0;
31+
}
32+
2733
const visualViewport = window.visualViewport;
2834
if (visualViewport == null) {
2935
// Defensive guard; not expected to run in supported environments

0 commit comments

Comments
 (0)