Skip to content

Commit

Permalink
Add some instances for testing the filter function
Browse files Browse the repository at this point in the history
  • Loading branch information
Anbo-WU committed Oct 18, 2024
1 parent 48d2d84 commit dd9d784
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1176,5 +1176,31 @@ describe('QuestionSubmissionFormComponent', () => {

expect(component.dropdownVisible[index]).toBe(true);
})

it('filterRecipients: should filter recipient list in the dropdown list and update dropdown visibility', ()=>{

const value = 'alex';
const index = 0;

component.model.recipientList = [
{ recipientIdentifier: '0', recipientName: 'Alice Betsy' },
{ recipientIdentifier: '1', recipientName: 'Benny Charles' },
{ recipientIdentifier: '2', recipientName: 'Group 2 | Tutorial 13 | Alex Kim' },
{ recipientIdentifier: '3', recipientName: 'Lecture #1 @ Room A | Jason Doe' },
{ recipientIdentifier: '4', recipientName: 'Lab Session *10* | Annie K. & John L.' },
{ recipientIdentifier: '5', recipientName: 'Group 3: Research Team | Dr. Alex Smith' }
];

component.getSelectionOptionLabel = (recipient: any) => recipient.recipientName;
component.filterRecipients(value, index);

// Testing for the filtered recipients based on 'alex'
expect(component.filteredRecipients[index].length).toBe(2);
expect(component.filteredRecipients[index][0].recipientName).toBe('Group 2 | Tutorial 13 | Alex Kim');
expect(component.filteredRecipients[index][1].recipientName).toBe('Group 3: Research Team | Dr. Alex Smith');

// Dropdown should be visible for the filtered results
expect(component.dropdownVisible[index]).toBe(true);
});

});

0 comments on commit dd9d784

Please sign in to comment.