@@ -22,7 +22,8 @@ import { render, fireEvent, within } from '@testing-library/svelte';
22
22
import InferenceRuntimeSelect from '/@/lib/select/InferenceRuntimeSelect.svelte' ;
23
23
import { InferenceType } from '@shared/models/IInference' ;
24
24
25
- const getExpectedOptions = ( ) : InferenceType [ ] => Object . values ( InferenceType ) . filter ( t => t !== InferenceType . NONE ) ;
25
+ const getFilteredOptions = ( exclude : InferenceType [ ] = [ ] ) : InferenceType [ ] =>
26
+ Object . values ( InferenceType ) . filter ( type => ! exclude . includes ( type ) ) ;
26
27
27
28
beforeEach ( ( ) => {
28
29
// mock scrollIntoView
@@ -39,7 +40,7 @@ test('Lists all runtime options', async () => {
39
40
await fireEvent . pointerUp ( input ) ;
40
41
41
42
const items = container . querySelectorAll ( 'div[class~="list-item"]' ) ;
42
- const expectedOptions = getExpectedOptions ( ) ;
43
+ const expectedOptions = getFilteredOptions ( ) ;
43
44
44
45
expect ( items . length ) . toBe ( expectedOptions . length ) ;
45
46
@@ -58,7 +59,7 @@ test('Selected value should be visible', async () => {
58
59
await fireEvent . pointerUp ( input ) ;
59
60
60
61
const items = container . querySelectorAll ( 'div[class~="list-item"]' ) ;
61
- const expectedOptions = getExpectedOptions ( ) ;
62
+ const expectedOptions = getFilteredOptions ( ) ;
62
63
63
64
await fireEvent . click ( items [ 0 ] ) ;
64
65
@@ -88,9 +89,9 @@ test('Exclude specific runtime from list', async () => {
88
89
expect ( itemTexts ) . not . toContain ( excludedType ) ;
89
90
} ) ;
90
91
91
- const includedTypes = Object . values ( InferenceType ) . filter ( t => t !== InferenceType . NONE && ! excluded . includes ( t ) ) ;
92
+ const expected = getFilteredOptions ( excluded ) ;
92
93
93
- includedTypes . forEach ( included => {
94
+ expected . forEach ( included => {
94
95
expect ( itemTexts ) . toContain ( included ) ;
95
96
} ) ;
96
97
} ) ;
0 commit comments