Files
iNaturalistReactNative/tests/unit/components/Match/AdditionalSuggestionsScroll.test.js
Ryan Stelly b78be9243d lint rule & autofix for "trailing comma" (#3299)
* (lint) MOB-1063 enforce trailing commas

* autofix trailing commas

* manually fix newly introduced maxlen violations

* add trailing comma convention to i18n build
2025-12-22 20:17:13 -06:00

53 lines
1.5 KiB
JavaScript

import { screen } from "@testing-library/react-native";
import AdditionalSuggestionsScroll
from "components/Match/AdditionalSuggestions/AdditionalSuggestionsScroll";
import React from "react";
import factory from "tests/factory";
import { renderComponent } from "tests/helpers/render";
describe( "AdditionalSuggestionsScroll", () => {
it( "returns null when not loading and otherSuggestions is empty", () => {
renderComponent(
<AdditionalSuggestionsScroll
otherSuggestions={[]}
suggestionsLoading={false}
onSuggestionChosen={jest.fn()}
/>,
);
expect( screen.queryByText( "It might also be" ) ).toBeFalsy();
expect( screen.queryByText( "It might be one of these" ) ).toBeFalsy();
} );
it( "shows ActivityIndicator when suggestionsLoading is true", () => {
renderComponent(
<AdditionalSuggestionsScroll
otherSuggestions={[]}
suggestionsLoading
onSuggestionChosen={jest.fn()}
/>,
);
expect( screen.getByRole( "progressbar" ) ).toBeVisible();
} );
it( "renders heading when noTopSuggestion is true", () => {
const suggestions = [
{
taxon: factory( "RemoteTaxon" ),
combined_score: 85,
},
];
renderComponent(
<AdditionalSuggestionsScroll
noTopSuggestion
otherSuggestions={suggestions}
suggestionsLoading={false}
onSuggestionChosen={jest.fn()}
/>,
);
expect( screen.getByText( "It might be one of these" ) ).toBeVisible();
} );
} );