@@ -61,22 +61,47 @@ describe('<SpecsListHeader />', { keystrokeDelay: 0 }, () => {
61
61
. should ( 'have.been.called' )
62
62
} )
63
63
64
- it ( 'shows the result count correctly' , ( ) => {
65
- const mountWithResultCount = ( count = 0 ) => {
64
+ it ( 'shows the count correctly when not searching ' , ( ) => {
65
+ const mountWithSpecCount = ( count = 0 ) => {
66
66
cy . mount ( ( ) => ( < div class = "max-w-800px p-12 resize overflow-auto" > < SpecsListHeader
67
67
modelValue = { '' }
68
- resultCount = { count }
68
+ specCount = { count }
69
69
/> </ div > ) )
70
70
}
71
71
72
- mountWithResultCount ( 0 )
72
+ mountWithSpecCount ( 0 )
73
73
cy . contains ( 'No Matches' )
74
74
. should ( 'be.visible' )
75
75
. and ( 'have.attr' , 'aria-live' , 'polite' )
76
76
77
- mountWithResultCount ( 1 )
77
+ mountWithSpecCount ( 1 )
78
78
cy . contains ( '1 Match' ) . should ( 'be.visible' )
79
- mountWithResultCount ( 100 )
79
+ mountWithSpecCount ( 100 )
80
80
cy . contains ( '100 Matches' ) . should ( 'be.visible' )
81
81
} )
82
+
83
+ it ( 'shows the count correctly while searching' , ( ) => {
84
+ const mountWithCounts = ( resultCount = 0 , specCount = 0 ) => {
85
+ cy . mount ( ( ) => ( < div class = "max-w-800px p-12 resize overflow-auto" > < SpecsListHeader
86
+ modelValue = { 'foo' }
87
+ resultCount = { resultCount }
88
+ specCount = { specCount }
89
+ /> </ div > ) )
90
+ }
91
+
92
+ mountWithCounts ( 0 , 0 )
93
+ cy . contains ( 'No Matches' )
94
+
95
+ mountWithCounts ( 0 , 22 )
96
+ cy . contains ( '0 of 22 Matches' )
97
+
98
+ mountWithCounts ( 0 , 1 )
99
+ cy . contains ( '0 of 1 Match' ) . should ( 'be.visible' )
100
+
101
+ mountWithCounts ( 1 , 1 )
102
+ cy . contains ( '1 of 1 Match' ) . should ( 'be.visible' )
103
+
104
+ mountWithCounts ( 5 , 22 )
105
+ cy . contains ( '5 of 22 Matches' ) . should ( 'be.visible' )
106
+ } )
82
107
} )
0 commit comments