Files
iNaturalistReactNative/tests/unit/components/ObsEdit/DatePicker.test.js
Johannes Klein 1823ae0d2f Some smaller layout changes on ObsEdit; plus fix for evidence list not scrolling to side of screens (#2452)
* Change text to size 2

* Change text size for date to Body2

* Change text size for other data to Body2

* Adjust tappable height for other data

* Adjust tappable height for date picker

* DatePicker TS

* Change padding of location section

* Push pixels to center icons with first line of text

* Fix a UI issue with evidence list not scrolling to the sides of the screen

* Align all icons at same vertical axis

* Apply margin to evidence list and iconic taxon list
2024-11-20 08:28:00 +01:00

48 lines
1.5 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
} );
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" );
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( );
} );
} );