mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 05:58:37 -04:00
* Extracted non-photo stuff from PhotoDisplay * Separate component for FaveButton * Prevent faves while signed out * Separate component for nav header * Stick nav header while scrolling until tabs * Nav header has slight gradient for visibility over white content * Renamed ObsDetails media components so they're not focused on photos * Data and layout changes leading up to sound player on ObsDetail * Add sound player to ObsDetails * Swiping away while playing should pause playback * Swiping back to sound and playing again should resume where you left off * Allow viewing media while offline (images may be cached) * Stop playback when navigating away from ObsDetails * Fetch sounds in Explore so we can show sound icon * Map all observation objects in explore with Realm-ish attributes
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
import Observation from "realmModels/Observation";
|
|
import factory from "tests/factory";
|
|
|
|
describe( "Observation", ( ) => {
|
|
describe( "mapObservationForUpload", ( ) => {
|
|
// observed_on is set by the server, clients specify the date with observed_on_string
|
|
it( "should not include observed_on", ( ) => {
|
|
expect(
|
|
Observation.mapObservationForUpload( { observed_on: "2020-01-01" } ).observed_on
|
|
).toBeUndefined( );
|
|
} );
|
|
} );
|
|
|
|
describe( "mapApiToRealm", ( ) => {
|
|
it(
|
|
"should assign user.prefers_community_taxa from user.preferences.prefers_community_taxa",
|
|
( ) => {
|
|
const mockApiObservation = {
|
|
user: {
|
|
preferences: {
|
|
prefers_community_taxa: false
|
|
}
|
|
}
|
|
};
|
|
expect(
|
|
Observation.mapApiToRealm( mockApiObservation ).user.prefers_community_taxa
|
|
).toEqual( mockApiObservation.user.preferences.prefers_community_taxa );
|
|
}
|
|
);
|
|
it( "should set _created_at to a date object without Realm", ( ) => {
|
|
expect( Observation.mapApiToRealm( { } )._created_at ).toBeInstanceOf( Date );
|
|
} );
|
|
it( "should create observationSounds from sounds", ( ) => {
|
|
const remoteSound = factory( "RemoteSound" );
|
|
const mappedObservation = Observation.mapApiToRealm( { sounds: [remoteSound] } );
|
|
expect( mappedObservation.observationSounds[0].file_url ).toEqual( remoteSound.file_url );
|
|
} );
|
|
} );
|
|
} );
|