@@ -64,15 +64,17 @@ const mockUseNextStation = useNextStation as jest.MockedFunction<
6464describe ( 'DevOverlay' , ( ) => {
6565 beforeEach ( ( ) => {
6666 // Default mock implementations for useAtomValue
67- // locationAtom, accuracyHistoryAtomの順で呼ばれる (useTelemetryEnabledは別途モック済み)
67+ // locationAtom, accuracyHistoryAtom, backgroundLocationTrackingAtomの順で呼ばれる
68+ // (useTelemetryEnabledは別途モック済み)
6869 mockUseAtomValue
6970 . mockReturnValueOnce ( {
7071 coords : {
7172 speed : 10 ,
7273 accuracy : 15 ,
7374 } ,
7475 } ) // locationAtom
75- . mockReturnValue ( [ 10 , 15 , 20 ] ) ; // accuracyHistoryAtom
76+ . mockReturnValueOnce ( [ 10 , 15 , 20 ] ) // accuracyHistoryAtom
77+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
7678
7779 mockUseDistanceToNextStation . mockReturnValue ( '500' ) ;
7880 mockUseNextStation . mockReturnValue ( {
@@ -106,6 +108,24 @@ describe('DevOverlay', () => {
106108 const { getByText } = render ( < DevOverlay /> ) ;
107109 expect ( getByText ( 'Telemetry: ON' ) ) . toBeTruthy ( ) ;
108110 } ) ;
111+
112+ it ( 'バックグラウンド位置情報のOFF状態を表示する' , ( ) => {
113+ const { getByText } = render ( < DevOverlay /> ) ;
114+ expect ( getByText ( 'BG Loc: OFF' ) ) . toBeTruthy ( ) ;
115+ } ) ;
116+
117+ it ( 'バックグラウンド位置情報のON状態を表示する' , ( ) => {
118+ mockUseAtomValue . mockReset ( ) ;
119+ mockUseAtomValue
120+ . mockReturnValueOnce ( {
121+ coords : { speed : 10 , accuracy : 15 } ,
122+ } ) // locationAtom
123+ . mockReturnValueOnce ( [ 10 , 15 , 20 ] ) // accuracyHistoryAtom
124+ . mockReturnValue ( true ) ; // backgroundLocationTrackingAtom
125+
126+ const { getByText } = render ( < DevOverlay /> ) ;
127+ expect ( getByText ( 'BG Loc: ON' ) ) . toBeTruthy ( ) ;
128+ } ) ;
109129 } ) ;
110130
111131 describe ( '位置情報の表示' , ( ) => {
@@ -138,7 +158,7 @@ describe('DevOverlay', () => {
138158 mockUseAtomValue
139159 . mockReturnValueOnce ( null ) // locationAtom
140160 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
141- . mockReturnValue ( { telemetryEnabled : true } ) ;
161+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
142162
143163 expect ( ( ) => {
144164 render ( < DevOverlay /> ) ;
@@ -152,7 +172,7 @@ describe('DevOverlay', () => {
152172 coords : { speed : null , accuracy : 15 } ,
153173 } ) // locationAtom
154174 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
155- . mockReturnValue ( { telemetryEnabled : true } ) ;
175+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
156176
157177 const { getByText } = render ( < DevOverlay /> ) ;
158178 expect ( getByText ( 'Speed: 0km/h' ) ) . toBeTruthy ( ) ;
@@ -165,7 +185,7 @@ describe('DevOverlay', () => {
165185 coords : { speed : - 5 , accuracy : 15 } ,
166186 } ) // locationAtom
167187 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
168- . mockReturnValue ( { telemetryEnabled : true } ) ;
188+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
169189
170190 const { getByText } = render ( < DevOverlay /> ) ;
171191 expect ( getByText ( 'Speed: 0km/h' ) ) . toBeTruthy ( ) ;
@@ -178,7 +198,7 @@ describe('DevOverlay', () => {
178198 coords : { speed : 10 , accuracy : null } ,
179199 } ) // locationAtom
180200 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
181- . mockReturnValue ( { telemetryEnabled : true } ) ;
201+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
182202
183203 const { getByText } = render ( < DevOverlay /> ) ;
184204 expect ( getByText ( 'Accuracy: m' ) ) . toBeTruthy ( ) ;
@@ -191,7 +211,7 @@ describe('DevOverlay', () => {
191211 coords : { speed : 10 , accuracy : 15 } ,
192212 } ) // locationAtom
193213 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
194- . mockReturnValue ( { telemetryEnabled : true } ) ;
214+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
195215
196216 expect ( ( ) => {
197217 render ( < DevOverlay /> ) ;
@@ -242,7 +262,7 @@ describe('DevOverlay', () => {
242262 coords : { speed : 0 , accuracy : 15 } ,
243263 } ) // locationAtom
244264 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
245- . mockReturnValue ( { telemetryEnabled : true } ) ;
265+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
246266
247267 const { getByText } = render ( < DevOverlay /> ) ;
248268 expect ( getByText ( 'Speed: 0km/h' ) ) . toBeTruthy ( ) ;
@@ -255,7 +275,7 @@ describe('DevOverlay', () => {
255275 coords : { speed : 13.89 , accuracy : 15 } , // 約50 km/h
256276 } ) // locationAtom
257277 . mockReturnValueOnce ( [ ] ) // accuracyHistoryAtom
258- . mockReturnValue ( { telemetryEnabled : true } ) ;
278+ . mockReturnValue ( false ) ; // backgroundLocationTrackingAtom
259279
260280 const { getByText } = render ( < DevOverlay /> ) ;
261281 expect ( getByText ( 'Speed: 50km/h' ) ) . toBeTruthy ( ) ;
0 commit comments