11import { render } from '@testing-library/react-native' ;
22import * as Application from 'expo-application' ;
33import { useAtomValue } from 'jotai' ;
4+ import { Dimensions } from 'react-native' ;
45import type { Station } from '~/@types/graphql' ;
56import {
67 accuracyHistoryAtom ,
@@ -68,6 +69,8 @@ const mockUseNextStation = useNextStation as jest.MockedFunction<
6869> ;
6970
7071describe ( 'DevOverlay' , ( ) => {
72+ const mockDimensionsGet = jest . spyOn ( Dimensions , 'get' ) ;
73+
7174 const setupAtomValues = ( {
7275 location = {
7376 coords : {
@@ -100,6 +103,12 @@ describe('DevOverlay', () => {
100103 } ;
101104
102105 beforeEach ( ( ) => {
106+ mockDimensionsGet . mockReturnValue ( {
107+ width : 393 ,
108+ height : 852 ,
109+ scale : 3 ,
110+ fontScale : 1 ,
111+ } as ReturnType < typeof Dimensions . get > ) ;
103112 setupAtomValues ( ) ;
104113 mockUseDistanceToNextStation . mockReturnValue ( '500' ) ;
105114 mockUseNextStation . mockReturnValue ( {
@@ -112,6 +121,7 @@ describe('DevOverlay', () => {
112121
113122 afterEach ( ( ) => {
114123 jest . clearAllMocks ( ) ;
124+ mockDimensionsGet . mockReset ( ) ;
115125 } ) ;
116126
117127 describe ( '基本的なレンダリング' , ( ) => {
@@ -155,6 +165,18 @@ describe('DevOverlay', () => {
155165 expect ( getByText ( 'BG LOC' ) ) . toBeTruthy ( ) ;
156166 expect ( getAllByText ( 'ON' ) ) . toHaveLength ( 2 ) ;
157167 } ) ;
168+
169+ it ( '横画面レイアウトを表示する' , ( ) => {
170+ mockDimensionsGet . mockReturnValue ( {
171+ width : 852 ,
172+ height : 393 ,
173+ scale : 3 ,
174+ fontScale : 1 ,
175+ } as ReturnType < typeof Dimensions . get > ) ;
176+
177+ const { getByTestId } = render ( < DevOverlay /> ) ;
178+ expect ( getByTestId ( 'dev-overlay-landscape' ) ) . toBeTruthy ( ) ;
179+ } ) ;
158180 } ) ;
159181
160182 describe ( '位置情報の表示' , ( ) => {
0 commit comments