Skip to content

Commit

Permalink
fix exlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sosek108 committed Feb 20, 2025
1 parent e1986c2 commit fe730a7
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions tests/perf-test/OptionsListUtils.perf-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {rand} from '@ngneat/falso';
import type * as NativeNavigation from '@react-navigation/native';
import Onyx from 'react-native-onyx';
import {measureFunction} from 'reassure';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import {createOptionList, filterAndOrderOptions, getMemberInviteOptions, getSearchOptions, getShareDestinationOptions, getShareLogOptions, getValidOptions} from '@libs/OptionsListUtils';
import type {OptionData} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -73,9 +73,18 @@ jest.mock('@react-navigation/native', () => {
};
});

const options = OptionsListUtils.createOptionList(personalDetails, reports);
const options = createOptionList(personalDetails, reports);

const getValidOptionsConfig = { betas: mockedBetas, includeRecentReports: true, includeTasks: true, includeThreads: true, includeMoneyRequests: true, includeMultipleParticipantReports: true, includeSelfDM: true, includeOwnedWorkspaceChats: true };
const getValidOptionsConfig = {
betas: mockedBetas,
includeRecentReports: true,
includeTasks: true,
includeThreads: true,
includeMoneyRequests: true,
includeMultipleParticipantReports: true,
includeSelfDM: true,
includeOwnedWorkspaceChats: true,
};

/* GetOption is the private function and is never called directly, we are testing the functions which call getOption with different params */
describe('OptionsListUtils', () => {
Expand All @@ -97,41 +106,41 @@ describe('OptionsListUtils', () => {
/* Testing getSearchOptions */
test('[OptionsListUtils] getSearchOptions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => OptionsListUtils.getSearchOptions(options, mockedBetas));
await measureFunction(() => getSearchOptions(options, mockedBetas));
});

/* Testing getShareLogOptions */
test('[OptionsListUtils] getShareLogOptions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => OptionsListUtils.getShareLogOptions(options, mockedBetas));
await measureFunction(() => getShareLogOptions(options, mockedBetas));
});

/* Testing getFilteredOptions */
test('[OptionsListUtils] getFilteredOptions with search value', async () => {
await waitForBatchedUpdates();
const formattedOptions = OptionsListUtils.getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, getValidOptionsConfig);
const formattedOptions = getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, getValidOptionsConfig);
await measureFunction(() => {
const result = OptionsListUtils.filterAndOrderOptions(formattedOptions, SEARCH_VALUE);
filterAndOrderOptions(formattedOptions, SEARCH_VALUE);
});
});
test('[OptionsListUtils] getFilteredOptions with empty search value', async () => {
await waitForBatchedUpdates();
const formattedOptions = OptionsListUtils.getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, getValidOptionsConfig);
const formattedOptions = getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, getValidOptionsConfig);
await measureFunction(() => {
const result = OptionsListUtils.filterAndOrderOptions(formattedOptions, '');
filterAndOrderOptions(formattedOptions, '');
});
});

/* Testing getShareDestinationOptions */
test('[OptionsListUtils] getShareDestinationOptions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => OptionsListUtils.getShareDestinationOptions(options.reports, options.personalDetails, mockedBetas));
await measureFunction(() => getShareDestinationOptions(options.reports, options.personalDetails, mockedBetas));
});

/* Testing getMemberInviteOptions */
test('[OptionsListUtils] getMemberInviteOptions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => OptionsListUtils.getMemberInviteOptions(options.personalDetails, mockedBetas));
await measureFunction(() => getMemberInviteOptions(options.personalDetails, mockedBetas));
});

test('[OptionsListUtils] worst case scenario with a search term that matches a subset of selectedOptions, filteredRecentReports, and filteredPersonalDetails', async () => {
Expand Down

0 comments on commit fe730a7

Please sign in to comment.