mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-06 06:35:57 -04:00
* fix: show observation datetime in the obs time zone I.e. it doesn't offset the observation datetime into the viewer's time zone. * test: adjust to literal times by default * chore: update to date-fns 3.0 * wip: show time zone names with all times * show time zone name whenever a time zone is passed to a formatting function * store observation IANA time zone in Realm Note that this required patching around a bug in Hermes in which it should be returning a GMT offset for the short time zone but is instead just returning GMT. * fix: omit time zone for unuploaded obs * feat: show relative time differences on ActivityItem headers * fix: hide zone/offset on ObsEdit before upload when signed in * fix: hide clock icon in activity item header in new default mode Also * stop using checkCamelAndSnakeCase when not necessary in DetailsTab.js * make POJO types only refer to other POJO types
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
import { screen } from "@testing-library/react-native";
|
|
import DatePicker from "components/ObsEdit/DatePicker.tsx";
|
|
import React from "react";
|
|
import factory from "tests/factory";
|
|
import { renderComponent } from "tests/helpers/render";
|
|
|
|
const mockLocalObservation = factory( "LocalObservation", {
|
|
observed_on_string: "2024-08-09T12:21"
|
|
} );
|
|
|
|
const mockRemoteObservation = factory( "RemoteObservation", {
|
|
// jest timezone is set to UTC time
|
|
time_observed_at: "2024-06-15T17:26:00-00:00",
|
|
observed_on_string: null,
|
|
observed_time_zone: "UTC"
|
|
} );
|
|
|
|
const mockLocalObservationNoDate = factory( "LocalObservation", {
|
|
observed_on_string: null
|
|
} );
|
|
|
|
describe( "DatePicker", ( ) => {
|
|
it( "has no accessibility errors", ( ) => {
|
|
const datePicker = <DatePicker />;
|
|
expect( datePicker ).toBeAccessible( );
|
|
} );
|
|
|
|
it( "displays date with no seconds from local observation", ( ) => {
|
|
renderComponent( <DatePicker currentObservation={mockLocalObservation} /> );
|
|
|
|
const date = screen.getByText( "08/09/2024, 12:21 PM" );
|
|
expect( date ).toBeVisible( );
|
|
} );
|
|
|
|
it( "displays date with no seconds from remote observation", ( ) => {
|
|
renderComponent( <DatePicker currentObservation={mockRemoteObservation} /> );
|
|
|
|
const date = screen.getByText( "06/15/2024, 5:26 PM (UTC)" );
|
|
expect( date ).toBeVisible( );
|
|
} );
|
|
|
|
it( "displays Add Date text when observation has no date", ( ) => {
|
|
renderComponent( <DatePicker currentObservation={mockLocalObservationNoDate} /> );
|
|
|
|
const addDateText = screen.getByText( "Add Date/Time" );
|
|
expect( addDateText ).toBeVisible( );
|
|
} );
|
|
} );
|