mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-19 05:47:33 -04:00
* Create ObsDetailsDefaultMode and rearrange items on top of screen * Move activity, details, and more into three different sections instead of tabs * Styling cleanup; change Activity name to Community * Fix scroll to activity item from Notifications * Add ObsDetailsDefaultMode unit tests * Show kebab menu on other users' observations
104 lines
2.5 KiB
JavaScript
104 lines
2.5 KiB
JavaScript
import { screen } from "@testing-library/react-native";
|
|
import DQAVoteButtons from "components/ObsDetailsDefaultMode/MoreSection/DQAVoteButtons";
|
|
import React from "react";
|
|
import factory from "tests/factory";
|
|
import { renderComponent } from "tests/helpers/render";
|
|
|
|
const mockUser = factory( "RemoteUser" );
|
|
const mockQualityMetrics = [
|
|
{
|
|
id: 0,
|
|
agree: true,
|
|
metric: "wild",
|
|
user_id: mockUser.id
|
|
}
|
|
];
|
|
|
|
const mockVotesNeedsID = [
|
|
factory( "RemoteVote", {
|
|
vote_scope: "needs_id",
|
|
user: mockUser,
|
|
user_id: mockUser.id
|
|
} )
|
|
];
|
|
|
|
// Mock useCurrentUser hook
|
|
jest.mock( "sharedHooks/useCurrentUser", ( ) => ( {
|
|
__esModule: true,
|
|
default: jest.fn( ( ) => ( {
|
|
id: mockUser.id
|
|
} ) )
|
|
} ) );
|
|
|
|
describe( "DQA Vote Buttons for wild metric", ( ) => {
|
|
test( "renders correct DQA user vote", async ( ) => {
|
|
renderComponent( <DQAVoteButtons
|
|
metric="wild"
|
|
votes={mockQualityMetrics}
|
|
setVote={jest.fn()}
|
|
loadingAgree={jest.fn()}
|
|
loadingDisagree={jest.fn()}
|
|
loadingMetric={jest.fn()}
|
|
removeVote={jest.fn()}
|
|
/> );
|
|
|
|
const button = await screen.findByTestId(
|
|
"DQAVoteButton.UserAgree"
|
|
);
|
|
expect( button ).toBeTruthy( );
|
|
} );
|
|
|
|
test( "renders correct DQA user vote number", async ( ) => {
|
|
renderComponent( <DQAVoteButtons
|
|
metric="wild"
|
|
votes={mockQualityMetrics}
|
|
setVote={jest.fn()}
|
|
loadingAgree={jest.fn()}
|
|
loadingDisagree={jest.fn()}
|
|
loadingMetric={jest.fn()}
|
|
removeVote={jest.fn()}
|
|
/> );
|
|
|
|
const voteNumber = await screen.findByText(
|
|
"1"
|
|
);
|
|
expect( voteNumber ).toBeTruthy( );
|
|
} );
|
|
} );
|
|
|
|
describe( "DQA Vote Buttons for needs_id metric", ( ) => {
|
|
test( "renders correct DQA user vote", async ( ) => {
|
|
renderComponent( <DQAVoteButtons
|
|
metric="needs_id"
|
|
votes={mockVotesNeedsID}
|
|
setVote={jest.fn()}
|
|
loadingAgree={jest.fn()}
|
|
loadingDisagree={jest.fn()}
|
|
loadingMetric={jest.fn()}
|
|
removeVote={jest.fn()}
|
|
/> );
|
|
|
|
const button = await screen.findByTestId(
|
|
"DQAVoteButton.UserAgree"
|
|
);
|
|
expect( button ).toBeTruthy( );
|
|
} );
|
|
|
|
test( "renders correct DQA user vote number", async ( ) => {
|
|
renderComponent( <DQAVoteButtons
|
|
metric="needs_id"
|
|
votes={mockVotesNeedsID}
|
|
setVote={jest.fn()}
|
|
loadingAgree={jest.fn()}
|
|
loadingDisagree={jest.fn()}
|
|
loadingMetric={jest.fn()}
|
|
removeVote={jest.fn()}
|
|
/> );
|
|
|
|
const voteNumber = await screen.findByText(
|
|
"1"
|
|
);
|
|
expect( voteNumber ).toBeTruthy( );
|
|
} );
|
|
} );
|