Skip to content

Commit

Permalink
Perf: add performance test case to validate filterAndOrderOptions fun…
Browse files Browse the repository at this point in the history
…ction with larger amount of data
  • Loading branch information
sosek108 committed Feb 19, 2025
1 parent 01b103c commit e1986c2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/perf-test/OptionsListUtils.perf-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ jest.mock('@react-navigation/native', () => {

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

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

Check failure on line 78 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Replace `·betas:·mockedBetas,·includeRecentReports:·true,·includeTasks:·true,·includeThreads:·true,·includeMoneyRequests:·true,·includeMultipleParticipantReports:·true,·includeSelfDM:·true,·includeOwnedWorkspaceChats:·true·` with `⏎····betas:·mockedBetas,⏎····includeRecentReports:·true,⏎····includeTasks:·true,⏎····includeThreads:·true,⏎····includeMoneyRequests:·true,⏎····includeMultipleParticipantReports:·true,⏎····includeSelfDM:·true,⏎····includeOwnedWorkspaceChats:·true,⏎`

Check failure on line 78 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Replace `·betas:·mockedBetas,·includeRecentReports:·true,·includeTasks:·true,·includeThreads:·true,·includeMoneyRequests:·true,·includeMultipleParticipantReports:·true,·includeSelfDM:·true,·includeOwnedWorkspaceChats:·true·` with `⏎····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', () => {
beforeAll(() => {
Expand Down Expand Up @@ -107,9 +109,16 @@ describe('OptionsListUtils', () => {
/* Testing getFilteredOptions */
test('[OptionsListUtils] getFilteredOptions with search value', async () => {
await waitForBatchedUpdates();
const formattedOptions = OptionsListUtils.getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, getValidOptionsConfig);

Check failure on line 112 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Delete `····`

Check failure on line 112 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Delete `····`
await measureFunction(() => {
const result = OptionsListUtils.filterAndOrderOptions(formattedOptions, SEARCH_VALUE);

Check failure on line 114 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'result' is assigned a value but never used

Check failure on line 114 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'result' is assigned a value but never used
});
});
test('[OptionsListUtils] getFilteredOptions with empty search value', async () => {
await waitForBatchedUpdates();
const formattedOptions = OptionsListUtils.getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, getValidOptionsConfig);
await measureFunction(() => {
const formattedOptions = OptionsListUtils.getValidOptions({reports: options.reports, personalDetails: options.personalDetails}, {betas: mockedBetas});
OptionsListUtils.filterAndOrderOptions(formattedOptions, SEARCH_VALUE);
const result = OptionsListUtils.filterAndOrderOptions(formattedOptions, '');

Check failure on line 121 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'result' is assigned a value but never used

Check failure on line 121 in tests/perf-test/OptionsListUtils.perf-test.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'result' is assigned a value but never used
});
});

Expand Down

0 comments on commit e1986c2

Please sign in to comment.