Skip to content

Commit

Permalink
AG-1328: improvements from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
hallieswan committed May 13, 2024
1 parent c613d04 commit 9c90151
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ describe('Component: Gene Nominated Targets', () => {
it('should correctly format display values', () => {
setUp([]);

expect(component.formatDisplayValue([])).toEqual('');
expect(
component.getCommaSeparatedStringOfUniqueSortedValues([])
).toEqual('');

expect(
component.formatDisplayValue([
component.getCommaSeparatedStringOfUniqueSortedValues([
'ACT',
'BLSA',
'Banner',
Expand All @@ -140,7 +142,16 @@ describe('Component: Gene Nominated Targets', () => {
).toEqual('ACT, Banner, BLSA');

expect(
component.formatDisplayValue(['Z', 'Y', 'X', 'A', 'B', 'C', 'B', 'C'])
component.getCommaSeparatedStringOfUniqueSortedValues([
'Z',
'Y',
'X',
'A',
'B',
'C',
'B',
'C',
])
).toEqual('A, B, C, X, Y, Z');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ export class GeneNominatedTargetsComponent implements OnInit {
inputDataArray = this.commaFlattenArray(inputDataArray);

// Populate targetNomination display fields
de.teams_display_value = this.formatDisplayValue(teamsArray);
de.study_display_value = this.formatDisplayValue(studyArray);
de.programs_display_value = this.formatDisplayValue(programsArray);
de.input_data_display_value = this.formatDisplayValue(inputDataArray);
de.teams_display_value =
this.getCommaSeparatedStringOfUniqueSortedValues(teamsArray);
de.study_display_value =
this.getCommaSeparatedStringOfUniqueSortedValues(studyArray);
de.programs_display_value =
this.getCommaSeparatedStringOfUniqueSortedValues(programsArray);
de.input_data_display_value =
this.getCommaSeparatedStringOfUniqueSortedValues(inputDataArray);

de.initial_nomination_display_value = initialNominationArray.length
? Math.min(...initialNominationArray)
Expand Down Expand Up @@ -176,7 +180,7 @@ export class GeneNominatedTargetsComponent implements OnInit {
return finalArray;
}

formatDisplayValue(inputArray: string[]) {
getCommaSeparatedStringOfUniqueSortedValues(inputArray: string[]) {
let display_value = '';
if (inputArray.length) {
display_value = inputArray
Expand Down

0 comments on commit 9c90151

Please sign in to comment.