Skip to content

Commit 4d9f1cb

Browse files
committed
開発者オーバレイの横画面テストを追加する
1 parent 6a9b339 commit 4d9f1cb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/components/DevOverlay.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { render } from '@testing-library/react-native';
22
import * as Application from 'expo-application';
33
import { useAtomValue } from 'jotai';
4+
import { Dimensions } from 'react-native';
45
import type { Station } from '~/@types/graphql';
56
import {
67
accuracyHistoryAtom,
@@ -68,6 +69,8 @@ const mockUseNextStation = useNextStation as jest.MockedFunction<
6869
>;
6970

7071
describe('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

Comments
 (0)