Commit a7e0f0a
authored
Simplify internal tests (#3720)
This PR simplifies the internal tests a bit.
1. Don't explicitly test if a component has a specific ID
1. Don't mock the `useId` hook if it's not necessary
What we care about more is that 2 components (E.g.: `MenuButton` and
`MenuItems`) are connected to each other. This is done via `id` and
`aria-controls` attributes. The exact ID is not important.
The main motivation for this is that every time we introduce some
`useId()` hook call somewhere, the IDs will shift and it will look like
some tests are broken.
If we are not explicitly testing the IDs, we also don't really care
about deterministic incrementing IDs in tests, so therefore we can
remove some `useId` mocking.
Note: some tests still have mocks like this (e.g.: `description.test.ts`
& `label.test.ts`) but that's because they have some snapshot tests.1 parent c9f8f30 commit a7e0f0a
File tree
9 files changed
+215
-922
lines changed- packages/@headlessui-react/src/components
- combobox
- dialog
- disclosure
- listbox
- popover
- radio-group
- switch
- tabs
9 files changed
+215
-922
lines changedLines changed: 90 additions & 364 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| |||
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 66 | + | |
72 | 67 | | |
73 | 68 | | |
74 | 69 | | |
| |||
584 | 579 | | |
585 | 580 | | |
586 | 581 | | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
| 582 | + | |
591 | 583 | | |
592 | 584 | | |
593 | 585 | | |
| |||
609 | 601 | | |
610 | 602 | | |
611 | 603 | | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
| 604 | + | |
616 | 605 | | |
617 | 606 | | |
618 | 607 | | |
| |||
754 | 743 | | |
755 | 744 | | |
756 | 745 | | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
| 746 | + | |
761 | 747 | | |
762 | 748 | | |
763 | 749 | | |
| |||
793 | 779 | | |
794 | 780 | | |
795 | 781 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
| 782 | + | |
800 | 783 | | |
801 | 784 | | |
802 | 785 | | |
| |||
838 | 821 | | |
839 | 822 | | |
840 | 823 | | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
| 824 | + | |
845 | 825 | | |
846 | 826 | | |
847 | 827 | | |
| |||
885 | 865 | | |
886 | 866 | | |
887 | 867 | | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
| 868 | + | |
892 | 869 | | |
893 | 870 | | |
894 | 871 | | |
| |||
935 | 912 | | |
936 | 913 | | |
937 | 914 | | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
| 915 | + | |
942 | 916 | | |
943 | 917 | | |
944 | 918 | | |
| |||
985 | 959 | | |
986 | 960 | | |
987 | 961 | | |
988 | | - | |
989 | | - | |
990 | | - | |
991 | | - | |
| 962 | + | |
992 | 963 | | |
993 | 964 | | |
994 | 965 | | |
| |||
0 commit comments