forked from inaturalist/iNaturalistReactNative
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
266 flash icon change (inaturalist#271)
* Add script to clean start * Add function to camera mock * Basic StandardCamera test setup * Display flash off icon in camera * Add accessibility labels to strings * Change to use testID for tests * Rename package script * Update vision-camera mock
- Loading branch information
Showing
13 changed files
with
183 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { fireEvent, render, screen } from "@testing-library/react-native"; | ||
import StandardCamera from "components/Camera/StandardCamera"; | ||
import { ObsEditContext } from "providers/contexts"; | ||
import React from "react"; | ||
import { View } from "react-native"; | ||
|
||
const mockedNavigate = jest.fn(); | ||
|
||
jest.mock( "@react-navigation/native", () => { | ||
const actualNav = jest.requireActual( "@react-navigation/native" ); | ||
return { | ||
...actualNav, | ||
useNavigation: () => ( { | ||
navigate: mockedNavigate | ||
} ), | ||
useRoute: () => ( {} ) | ||
}; | ||
} ); | ||
|
||
const mockValue = { | ||
addCameraPhotosToCurrentObservation: jest.fn(), | ||
allObsPhotoUris: [], | ||
cameraPreviewUris: [] | ||
}; | ||
|
||
const mockView = <View />; | ||
jest.mock( "components/Camera/CameraView", () => ( { | ||
__esModule: true, | ||
default: ( ) => mockView | ||
} ) ); | ||
|
||
jest.mock( "components/Camera/FadeInOutView", () => ( { | ||
__esModule: true, | ||
default: () => mockView | ||
} ) ); | ||
|
||
jest.mock( "components/Camera/PhotoPreview", () => ( { | ||
__esModule: true, | ||
default: () => mockView | ||
} ) ); | ||
|
||
const renderStandardCamera = () => render( | ||
<ObsEditContext.Provider value={mockValue}> | ||
<StandardCamera /> | ||
</ObsEditContext.Provider> | ||
); | ||
|
||
describe( "StandardCamera", ( ) => { | ||
test( "should first render with flash disabled", async () => { | ||
renderStandardCamera(); | ||
|
||
await screen.findByTestId( "flash-button-label-flash-off" ); | ||
} ); | ||
|
||
test( "should change to flash enabled on button press", async () => { | ||
renderStandardCamera(); | ||
|
||
const flashButton = await screen.findByTestId( | ||
"flash-button-label-flash-off" | ||
); | ||
fireEvent.press( flashButton ); | ||
|
||
await screen.findByTestId( "flash-button-label-flash" ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters