diff --git a/projects/components/src/select/select-option.component.ts b/projects/components/src/select/select-option.component.ts index ba45876ce..afc8c020c 100644 --- a/projects/components/src/select/select-option.component.ts +++ b/projects/components/src/select/select-option.component.ts @@ -15,6 +15,9 @@ export class SelectOptionComponent implements OnChanges, SelectOption { @Input() public label!: string; + @Input() + public selectedLabel?: string; + @Input() public style: SelectOptionStyle = SelectOptionStyle.Default; diff --git a/projects/components/src/select/select-option.ts b/projects/components/src/select/select-option.ts index 1efc3f034..23aa6f419 100644 --- a/projects/components/src/select/select-option.ts +++ b/projects/components/src/select/select-option.ts @@ -1,6 +1,7 @@ export interface SelectOption { value: V; label: string; + selectedLabel?: string; icon?: string; iconColor?: string; } diff --git a/projects/components/src/select/select.component.test.ts b/projects/components/src/select/select.component.test.ts index e58ef9bf8..91780cbaf 100644 --- a/projects/components/src/select/select.component.test.ts +++ b/projects/components/src/select/select.component.test.ts @@ -27,10 +27,10 @@ describe('Select Component', () => { const selectionOptions = [ { label: 'first', value: 'first-value' }, { label: 'second', value: 'second-value' }, - { label: 'third', value: 'third-value' } + { label: 'third', value: 'third-value', selectedLabel: 'Third Value!!!' } ]; - test('should display intial selection', fakeAsync(() => { + test('should display initial selection', fakeAsync(() => { spectator = hostFactory( ` @@ -127,7 +127,7 @@ describe('Select Component', () => { spectator = hostFactory( ` - + `, { @@ -140,6 +140,7 @@ describe('Select Component', () => { ); spectator.tick(); + expect(spectator.query('.trigger-content')).toHaveText(selectionOptions[1].label); spectator.click('.trigger-content'); const optionElements = spectator.queryAll('.select-option', { root: true }); @@ -147,7 +148,7 @@ describe('Select Component', () => { expect(onChange).toHaveBeenCalledTimes(1); expect(onChange).toHaveBeenCalledWith(selectionOptions[2].value); - expect(spectator.element).toHaveText(selectionOptions[2].label); + expect(spectator.query('.trigger-content')).toHaveText(selectionOptions[2].selectedLabel!); flush(); })); diff --git a/projects/components/src/select/select.component.ts b/projects/components/src/select/select.component.ts index 8fee26acc..30d6c24b6 100644 --- a/projects/components/src/select/select.component.ts +++ b/projects/components/src/select/select.component.ts @@ -54,7 +54,8 @@ import { SelectSize } from './select-size'; > - + +