Skip to content

Commit

Permalink
use generateCommaList
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAkhmetov committed Oct 8, 2024
1 parent c981781 commit 596c998
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ it('checks if dataset is published', () => {
it('counts pipelines and their occurrences', () => {
const { pipelinesText, pipelineCountsText } = usePipelineCountsInfo(testDatasets.map((dataset) => dataset._source));
expect(pipelinesText).toBe('Pipelines (2)');
expect(pipelineCountsText).toBe('Cytokit + SPRM (2), Segmentation Mask');
expect(pipelineCountsText).toBe('Cytokit + SPRM (2) and Segmentation Mask');
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMemo } from 'react';
import { ProcessedDatasetInfo, useProcessedDatasets } from 'js/pages/Dataset/hooks';
import { generateCommaList } from 'js/helpers/functions';

export function createdByCentralProcess(dataset: Pick<ProcessedDatasetInfo, 'creation_action'>) {
return dataset.creation_action === 'Central Process';
Expand Down Expand Up @@ -53,9 +54,9 @@ export function usePipelineCountsInfo(datasets: Pick<ProcessedDatasetInfo, 'pipe
{} as Record<string, number>,
);
const pipelinesText = `Pipelines (${Object.keys(pipelineCounts).length})`;
const pipelineCountsText = Object.entries(pipelineCounts)
.map(([pipeline, count]) => (count > 1 ? `${pipeline} (${count})` : pipeline))
.join(', ');
const pipelineCountsText = generateCommaList(
Object.entries(pipelineCounts).map(([pipeline, count]) => (count > 1 ? `${pipeline} (${count})` : pipeline)),
);

return {
pipelinesText,
Expand Down

0 comments on commit 596c998

Please sign in to comment.