@@ -40,8 +40,7 @@ function getFixture() {
40
40
` ;
41
41
}
42
42
43
- function setupTest ( ) {
44
- const root = getFixture ( ) ;
43
+ function setupTest ( root = getFixture ( ) ) {
45
44
const MockFoundationCtor = td . constructor ( MDCListFoundation ) ;
46
45
const mockFoundation = new MockFoundationCtor ( ) ;
47
46
const component = new MDCList ( root , mockFoundation ) ;
@@ -54,6 +53,25 @@ test('attachTo initializes and returns a MDCList instance', () => {
54
53
assert . isTrue ( MDCList . attachTo ( getFixture ( ) ) instanceof MDCList ) ;
55
54
} ) ;
56
55
56
+ test ( 'component calls setVerticalOrientation on the foundation if aria-orientation is not set' , ( ) => {
57
+ const { mockFoundation} = setupTest ( ) ;
58
+ td . verify ( mockFoundation . setVerticalOrientation ( true ) , { times : 1 } ) ;
59
+ } ) ;
60
+
61
+ test ( 'component calls setVerticalOrientation(false) on the foundation if aria-orientation=horizontal' , ( ) => {
62
+ const root = getFixture ( ) ;
63
+ root . setAttribute ( 'aria-orientation' , 'horizontal' ) ;
64
+ const { mockFoundation} = setupTest ( root ) ;
65
+ td . verify ( mockFoundation . setVerticalOrientation ( false ) , { times : 1 } ) ;
66
+ } ) ;
67
+
68
+ test ( 'component calls setVerticalOrientation(true) on the foundation if aria-orientation=vertical' , ( ) => {
69
+ const root = getFixture ( ) ;
70
+ root . setAttribute ( 'aria-orientation' , 'vertical' ) ;
71
+ const { mockFoundation} = setupTest ( root ) ;
72
+ td . verify ( mockFoundation . setVerticalOrientation ( true ) , { times : 1 } ) ;
73
+ } ) ;
74
+
57
75
test ( '#adapter.getListItemCount returns correct number of list items' , ( ) => {
58
76
const { root, component} = setupTest ( ) ;
59
77
document . body . appendChild ( root ) ;
@@ -177,33 +195,33 @@ test('#adapter.focusItemAtIndex focuses the list item at the index specified', (
177
195
} ) ;
178
196
179
197
test ( 'adapter#isListItem returns true if the element is a list item' , ( ) => {
180
- const { root, component} = setupTest ( true ) ;
198
+ const { root, component} = setupTest ( ) ;
181
199
const item1 = root . querySelectorAll ( '.mdc-list-item' ) [ 0 ] ;
182
200
assert . isTrue ( component . getDefaultFoundation ( ) . adapter_ . isListItem ( item1 ) ) ;
183
201
} ) ;
184
202
185
203
test ( 'adapter#isListItem returns false if the element is a not a list item' , ( ) => {
186
- const { root, component} = setupTest ( true ) ;
204
+ const { root, component} = setupTest ( ) ;
187
205
const item1 = root . querySelectorAll ( '.mdc-list-item button' ) [ 0 ] ;
188
206
assert . isFalse ( component . getDefaultFoundation ( ) . adapter_ . isListItem ( item1 ) ) ;
189
207
} ) ;
190
208
191
209
test ( 'adapter#isElementFocusable returns true if the element is a focusable list item sub-element' , ( ) => {
192
- const { root, component} = setupTest ( true ) ;
210
+ const { root, component} = setupTest ( ) ;
193
211
const item1 = root . querySelectorAll ( '.mdc-list-item button' ) [ 0 ] ;
194
212
assert . isTrue ( component . getDefaultFoundation ( ) . adapter_ . isElementFocusable ( item1 ) ) ;
195
213
} ) ;
196
214
197
215
test ( 'adapter#isElementFocusable returns false if the element is not a focusable list item sub-element' ,
198
216
( ) => {
199
- const { root, component} = setupTest ( true ) ;
217
+ const { root, component} = setupTest ( ) ;
200
218
const item1 = root . querySelectorAll ( '.mdc-list-item' ) [ 2 ] ;
201
219
assert . isFalse ( component . getDefaultFoundation ( ) . adapter_ . isElementFocusable ( item1 ) ) ;
202
220
} ) ;
203
221
204
222
test ( 'adapter#isElementFocusable returns false if the element is null/undefined' ,
205
223
( ) => {
206
- const { component} = setupTest ( true ) ;
224
+ const { component} = setupTest ( ) ;
207
225
assert . isFalse ( component . getDefaultFoundation ( ) . adapter_ . isElementFocusable ( ) ) ;
208
226
} ) ;
209
227
@@ -231,8 +249,8 @@ test('layout adds tabindex=-1 to all list item button/a elements', () => {
231
249
232
250
test ( 'vertical calls setVerticalOrientation on foundation' , ( ) => {
233
251
const { component, mockFoundation} = setupTest ( ) ;
234
- component . vertical = true ;
235
- td . verify ( mockFoundation . setVerticalOrientation ( true ) , { times : 1 } ) ;
252
+ component . vertical = false ;
253
+ td . verify ( mockFoundation . setVerticalOrientation ( false ) , { times : 1 } ) ;
236
254
} ) ;
237
255
238
256
test ( 'wrapFocus calls setWrapFocus on foundation' , ( ) => {
0 commit comments