@@ -517,8 +517,8 @@ test.describe('Props', () => {
517
517
518
518
test . describe ( 'uncontrolled' , ( ) => {
519
519
test ( `GIVEN an uncontrolled select with a value prop on the root component
520
- WHEN the value data matches the fourth option
521
- THEN the selected value should be the data passed to the value prop` , async ( {
520
+ WHEN the value data matches the fourth option
521
+ THEN the selected value should be the data passed to the value prop` , async ( {
522
522
page,
523
523
} ) => {
524
524
const { getValue, getOptions } = await setup ( page , 'select-uncontrolled-test' ) ;
@@ -529,10 +529,8 @@ test.describe('Props', () => {
529
529
} ) ;
530
530
531
531
test ( `GIVEN an uncontrolled select with a value prop on the root component
532
- WHEN the value prop data matches the fourth option
533
- THEN the fourth option should have data-highlighted set to true` , async ( {
534
- page,
535
- } ) => {
532
+ WHEN the value prop data matches the fourth option
533
+ THEN the fourth option should have data-highlighted` , async ( { page } ) => {
536
534
const { getValue, getOptions } = await setup ( page , 'select-uncontrolled-test' ) ;
537
535
538
536
const options = await getOptions ( ) ;
@@ -541,8 +539,8 @@ test.describe('Props', () => {
541
539
} ) ;
542
540
543
541
test ( `GIVEN an uncontrolled select with a value prop on the root component
544
- WHEN the value prop data matches the fourth option
545
- THEN the fourth option should have aria-selected set to true` , async ( {
542
+ WHEN the value prop data matches the fourth option
543
+ THEN the fourth option should have aria-selected set to true` , async ( {
546
544
page,
547
545
} ) => {
548
546
const { getValue, getOptions } = await setup ( page , 'select-uncontrolled-test' ) ;
@@ -553,8 +551,8 @@ test.describe('Props', () => {
553
551
} ) ;
554
552
555
553
test ( `GIVEN an uncontrolled select with a value prop on the root component
556
- WHEN the value data does NOT match any option
557
- THEN fallback to the placeholder` , async ( { page } ) => {
554
+ WHEN the value data does NOT match any option
555
+ THEN fallback to the placeholder` , async ( { page } ) => {
558
556
const { getValue } = await setup ( page , 'select-wrong-value-test' ) ;
559
557
560
558
/**
@@ -564,16 +562,40 @@ test.describe('Props', () => {
564
562
} ) ;
565
563
} ) ;
566
564
567
- // test.describe('controlled', () => {
568
- // test(`GIVEN a controlled select with a bind:value prop on the root component
569
- // WHEN the signal data matches the second option
570
- // THEN the selected value should be the data passed to the value prop`, async ({
571
- // page,
572
- // }) => {
573
- // const { getValue, getOptions } = await setup(page, 'select-uncontrolled -test');
565
+ test . describe ( 'controlled' , ( ) => {
566
+ test ( `GIVEN a controlled select with a bind:value prop on the root component
567
+ WHEN the signal data matches the second option
568
+ THEN the selected value should be the data passed to the value prop` , async ( {
569
+ page,
570
+ } ) => {
571
+ const { getValue, getOptions } = await setup ( page , 'select-controlled -test' ) ;
574
572
575
- // const options = await getOptions();
576
- // expect(await getValue()).toEqual(await options[1].textContent());
577
- // });
578
- // });
573
+ const options = await getOptions ( ) ;
574
+ expect ( await getValue ( ) ) . toEqual ( await options [ 1 ] . textContent ( ) ) ;
575
+ } ) ;
576
+
577
+ test ( `GIVEN a controlled select with a bind:value prop on the root component
578
+ WHEN the signal data matches the second option
579
+ THEN the selected value should should have data-highlighted` , async ( {
580
+ page,
581
+ } ) => {
582
+ const { getValue, getOptions } = await setup ( page , 'select-controlled-test' ) ;
583
+
584
+ const options = await getOptions ( ) ;
585
+ expect ( await getValue ( ) ) . toEqual ( await options [ 1 ] . textContent ( ) ) ;
586
+ await expect ( options [ 1 ] ) . toHaveAttribute ( 'data-highlighted' ) ;
587
+ } ) ;
588
+
589
+ test ( `GIVEN an controlled select with a bind:value prop on the root component
590
+ WHEN the signal data matches the second option
591
+ THEN the second option should have aria-selected set to true` , async ( {
592
+ page,
593
+ } ) => {
594
+ const { getValue, getOptions } = await setup ( page , 'select-controlled-test' ) ;
595
+
596
+ const options = await getOptions ( ) ;
597
+ expect ( await getValue ( ) ) . toEqual ( await options [ 1 ] . textContent ( ) ) ;
598
+ await expect ( options [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
599
+ } ) ;
600
+ } ) ;
579
601
} ) ;
0 commit comments