Skip to content

Commit 8a50759

Browse files
dschmidtLukasHirt
authored andcommitted
tests: add regression test for OcSelect.getOptionLabel
1 parent d50c2cf commit 8a50759

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/design-system/src/components/OcSelect/OcSelect.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ describe('OcSelect', () => {
5858
options[0].customLabel
5959
)
6060
})
61+
it('displays with a custom label function', () => {
62+
const options = [{ customLabel: 'label1' }, { customLabel: 'label2' }]
63+
const wrapper = getWrapper<(typeof options)[0]>({
64+
options,
65+
modelValue: options[0],
66+
getOptionLabel: (o) => o.customLabel
67+
})
68+
expect(wrapper.findAll(selectors.selectedOptions).at(0).text()).toEqual(
69+
options[0].customLabel
70+
)
71+
})
6172
it('can be cleared if multi-select is allowed', () => {
6273
const options = [{ label: 'label1' }, { label: 'label2' }]
6374
const wrapper = getWrapper({ options, modelValue: options[0], multiple: true })
@@ -87,9 +98,13 @@ describe('OcSelect', () => {
8798
})
8899
})
89100

90-
function getWrapper(
101+
function getWrapper<T>(
91102
props: Partial<
92-
PartialComponentProps<typeof OcSelect> & { options: unknown[]; modelValue: unknown }
103+
Omit<PartialComponentProps<typeof OcSelect>, 'getOptionLabel'> & {
104+
options: T[]
105+
getOptionLabel: (o: T) => string
106+
modelValue: T
107+
}
93108
> = {}
94109
) {
95110
return mount(OcSelect, {

0 commit comments

Comments
 (0)