@@ -20,6 +20,10 @@ describe("calcite-block-section", () => {
20
20
propertyName : "open" ,
21
21
value : true ,
22
22
} ,
23
+ {
24
+ propertyName : "expanded" ,
25
+ value : true ,
26
+ } ,
23
27
] ) ;
24
28
} ) ;
25
29
@@ -29,6 +33,10 @@ describe("calcite-block-section", () => {
29
33
propertyName : "open" ,
30
34
defaultValue : false ,
31
35
} ,
36
+ {
37
+ propertyName : "expanded" ,
38
+ defaultValue : false ,
39
+ } ,
32
40
{
33
41
propertyName : "toggleDisplay" ,
34
42
defaultValue : "button" ,
@@ -43,7 +51,7 @@ describe("calcite-block-section", () => {
43
51
describe ( "setFocus" , ( ) => {
44
52
describe ( "focuses toggle switch" , ( ) => {
45
53
focusable (
46
- html `< calcite-block-section text ="text " toggle-display ="switch " open >
54
+ html `< calcite-block-section text ="text " toggle-display ="switch " expanded >
47
55
< div > some content</ div >
48
56
</ calcite-block-section > ` ,
49
57
{
@@ -54,7 +62,7 @@ describe("calcite-block-section", () => {
54
62
55
63
describe ( "focuses toggle button" , ( ) => {
56
64
focusable (
57
- html `< calcite-block-section text ="text " toggle-display ="button " open >
65
+ html `< calcite-block-section text ="text " toggle-display ="button " expanded >
58
66
< div > some content</ div >
59
67
</ calcite-block-section > ` ,
60
68
{
@@ -67,13 +75,13 @@ describe("calcite-block-section", () => {
67
75
describe ( "toggle-display = 'switch'" , ( ) => {
68
76
describe ( "accessible" , ( ) => {
69
77
accessible ( html `
70
- < calcite-block-section text ="text " toggle-display ="switch " open >
78
+ < calcite-block-section text ="text " toggle-display ="switch " expanded >
71
79
< div > some content</ div >
72
80
</ calcite-block-section >
73
81
` ) ;
74
82
} ) ;
75
83
76
- describe ( "accessible: when closed " , ( ) => {
84
+ describe ( "accessible: when collapsed " , ( ) => {
77
85
accessible ( html `
78
86
< calcite-block-section text ="text " toggle-display ="switch ">
79
87
< div > some content</ div >
@@ -96,7 +104,7 @@ describe("calcite-block-section", () => {
96
104
97
105
it ( "renders section text" , async ( ) => {
98
106
const page = await newE2EPage ( {
99
- html : `<calcite-block-section text="test text" open toggle-display="switch"></calcite-block-section>` ,
107
+ html : `<calcite-block-section text="test text" expanded toggle-display="switch"></calcite-block-section>` ,
100
108
} ) ;
101
109
const element = await page . find ( `calcite-block-section >>> .${ CSS . toggle } ` ) ;
102
110
expect ( element . textContent ) . toBe ( "test text" ) ;
@@ -105,11 +113,11 @@ describe("calcite-block-section", () => {
105
113
106
114
describe ( "toggle-display = 'button' (default)" , ( ) => {
107
115
describe ( "accessible" , ( ) => {
108
- describe ( "accessible: when open " , ( ) => {
109
- accessible ( html `< calcite-block-section text ="text " open > < div > some content</ div > </ calcite-block-section > ` ) ;
116
+ describe ( "accessible: when expanded " , ( ) => {
117
+ accessible ( html `< calcite-block-section text ="text " expanded > < div > some content</ div > </ calcite-block-section > ` ) ;
110
118
} ) ;
111
119
112
- describe ( "accessible: when closed " , ( ) => {
120
+ describe ( "accessible: when collapsed " , ( ) => {
113
121
accessible ( html `< calcite-block-section text ="text "> < div > some content</ div > </ calcite-block-section > ` ) ;
114
122
} ) ;
115
123
} ) ;
@@ -126,6 +134,24 @@ describe("calcite-block-section", () => {
126
134
} ) ;
127
135
} ) ;
128
136
137
+ // Broader functionality related to the 'expanded' prop is covered in the `expanded` tests.
138
+ it ( "should map deprecated 'open' prop to 'expanded' prop" , async ( ) => {
139
+ const page = await newE2EPage ( {
140
+ html : html `< calcite-block-section > </ calcite-block-section > ` ,
141
+ } ) ;
142
+ const blockSection = await page . find ( "calcite-block-section" ) ;
143
+
144
+ expect ( await blockSection . getProperty ( "expanded" ) ) . toBe ( false ) ;
145
+
146
+ blockSection . setProperty ( "open" , true ) ;
147
+ await page . waitForChanges ( ) ;
148
+ expect ( await blockSection . getProperty ( "expanded" ) ) . toBe ( true ) ;
149
+
150
+ blockSection . setProperty ( "open" , false ) ;
151
+ await page . waitForChanges ( ) ;
152
+ expect ( await blockSection . getProperty ( "expanded" ) ) . toBe ( false ) ;
153
+ } ) ;
154
+
129
155
describe ( "status = 'invalid'" , ( ) => {
130
156
it ( "displays a status indicator when `status` is an accepted value" , async ( ) => {
131
157
const page = await newE2EPage ( {
@@ -153,17 +179,17 @@ describe("calcite-block-section", () => {
153
179
154
180
expect ( await content . isVisible ( ) ) . toBe ( false ) ;
155
181
156
- element . setProperty ( "open " , true ) ;
182
+ element . setProperty ( "expanded " , true ) ;
157
183
await page . waitForChanges ( ) ;
158
- element = await page . find ( "calcite-block-section[open ]" ) ;
184
+ element = await page . find ( "calcite-block-section[expanded ]" ) ;
159
185
content = await page . find ( `calcite-block-section >>> .${ CSS . content } ` ) ;
160
186
161
187
expect ( element ) . toBeTruthy ( ) ;
162
188
expect ( await content . isVisible ( ) ) . toBe ( true ) ;
163
189
164
- element . setProperty ( "open " , false ) ;
190
+ element . setProperty ( "expanded " , false ) ;
165
191
await page . waitForChanges ( ) ;
166
- element = await page . find ( "calcite-block-section[open ]" ) ;
192
+ element = await page . find ( "calcite-block-section[expanded ]" ) ;
167
193
content = await page . find ( `calcite-block-section >>> .${ CSS . content } ` ) ;
168
194
169
195
expect ( element ) . toBeNull ( ) ;
@@ -181,13 +207,13 @@ describe("calcite-block-section", () => {
181
207
await toggle . click ( ) ;
182
208
183
209
expect ( toggleSpy ) . toHaveReceivedEventTimes ( expectedClickEvents ++ ) ;
184
- expect ( await element . getProperty ( "open " ) ) . toBe ( true ) ;
210
+ expect ( await element . getProperty ( "expanded " ) ) . toBe ( true ) ;
185
211
expect ( toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "true" ) ;
186
212
187
213
await toggle . click ( ) ;
188
214
189
215
expect ( toggleSpy ) . toHaveReceivedEventTimes ( expectedClickEvents ++ ) ;
190
- expect ( await element . getProperty ( "open " ) ) . toBe ( false ) ;
216
+ expect ( await element . getProperty ( "expanded " ) ) . toBe ( false ) ;
191
217
expect ( toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "false" ) ;
192
218
193
219
if ( ( await element . getProperty ( "toggleDisplay" ) ) === "switch" ) {
@@ -196,13 +222,13 @@ describe("calcite-block-section", () => {
196
222
await switchToggle . click ( ) ;
197
223
198
224
expect ( toggleSpy ) . toHaveReceivedEventTimes ( expectedClickEvents ++ ) ;
199
- expect ( await element . getProperty ( "open " ) ) . toBe ( true ) ;
225
+ expect ( await element . getProperty ( "expanded " ) ) . toBe ( true ) ;
200
226
expect ( toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "true" ) ;
201
227
202
228
await switchToggle . click ( ) ;
203
229
204
230
expect ( toggleSpy ) . toHaveReceivedEventTimes ( expectedClickEvents ++ ) ;
205
- expect ( await element . getProperty ( "open " ) ) . toBe ( false ) ;
231
+ expect ( await element . getProperty ( "expanded " ) ) . toBe ( false ) ;
206
232
expect ( toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "false" ) ;
207
233
}
208
234
@@ -224,22 +250,22 @@ describe("calcite-block-section", () => {
224
250
await page . waitForChanges ( ) ;
225
251
226
252
expect ( toggleSpy ) . toHaveReceivedEventTimes ( expectedClickEvents ++ ) ;
227
- expect ( await element . getProperty ( "open " ) ) . toBe ( true ) ;
253
+ expect ( await element . getProperty ( "expanded " ) ) . toBe ( true ) ;
228
254
expect ( toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "true" ) ;
229
255
230
256
await keyboardToggleEmitter . press ( "Enter" ) ;
231
257
await page . waitForChanges ( ) ;
232
258
233
259
expect ( toggleSpy ) . toHaveReceivedEventTimes ( expectedClickEvents ++ ) ;
234
- expect ( await element . getProperty ( "open " ) ) . toBe ( false ) ;
260
+ expect ( await element . getProperty ( "expanded " ) ) . toBe ( false ) ;
235
261
expect ( toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "false" ) ;
236
262
}
237
263
238
264
describe ( "theme" , ( ) => {
239
265
describe ( "default" , ( ) => {
240
266
themed (
241
267
html `
242
- < calcite-block-section text ="Planes " open icon-end ="pen " icon-start ="pen " text ="a block-section ">
268
+ < calcite-block-section text ="Planes " expanded icon-end ="pen " icon-start ="pen " text ="a block-section ">
243
269
< p > Block section content</ p >
244
270
</ calcite-block-section >
245
271
` ,
0 commit comments