@@ -26,6 +26,8 @@ import MDCTopAppBarFoundation from '../../../packages/mdc-top-app-bar/foundation
26
26
import MDCFixedTopAppBarFoundation from '../../../packages/mdc-top-app-bar/fixed/foundation' ;
27
27
import MDCShortTopAppBarFoundation from '../../../packages/mdc-top-app-bar/short/foundation' ;
28
28
29
+ const MENU_ICONS_COUNT = 3 ;
30
+
29
31
function getFixture ( removeIcon ) {
30
32
const html = bel `
31
33
<div>
@@ -66,11 +68,6 @@ function getFixture(removeIcon) {
66
68
return html ;
67
69
}
68
70
69
- function getIconsCount ( root ) {
70
- const selector = strings . ACTION_ITEM_SELECTOR + ',' + strings . NAVIGATION_ICON_SELECTOR ;
71
- return root . querySelectorAll ( selector ) . length ;
72
- }
73
-
74
71
class FakeRipple {
75
72
constructor ( root ) {
76
73
this . root = root ;
@@ -96,20 +93,19 @@ test('attachTo initializes and returns an MDCTopAppBar instance', () => {
96
93
97
94
test ( 'constructor instantiates icon ripples for all icons' , ( ) => {
98
95
const rippleFactory = td . function ( ) ;
99
- td . when ( rippleFactory ( td . matchers . anything ( ) ) ) . thenReturn ( ( el ) => new FakeRipple ( el ) ) ;
100
- const { root } = setupTest ( /** removeIcon */ false , rippleFactory ) ;
96
+ // Including navigation icon.
97
+ const totalIcons = MENU_ICONS_COUNT + 1 ;
101
98
102
- const totalIcons = getIconsCount ( root ) ;
103
- td . verify ( rippleFactory ( td . matchers . anything ( ) ) , { times : totalIcons } ) ;
99
+ td . when ( rippleFactory ( td . matchers . anything ( ) ) , { times : totalIcons } ) . thenReturn ( ( el ) => new FakeRipple ( el ) ) ;
100
+ setupTest ( /** removeIcon */ false , rippleFactory ) ;
104
101
} ) ;
105
102
106
103
test ( 'constructor does not instantiate ripple for nav icon when not present' , ( ) => {
107
104
const rippleFactory = td . function ( ) ;
108
- td . when ( rippleFactory ( td . matchers . anything ( ) ) ) . thenReturn ( ( el ) => new FakeRipple ( el ) ) ;
109
- const { root} = setupTest ( /** removeIcon */ true , rippleFactory ) ;
105
+ const totalIcons = MENU_ICONS_COUNT ;
110
106
111
- const totalIcons = getIconsCount ( root ) ;
112
- td . verify ( rippleFactory ( td . matchers . anything ( ) ) , { times : totalIcons } ) ;
107
+ td . when ( rippleFactory ( td . matchers . anything ( ) ) , { times : totalIcons } ) . thenReturn ( ( el ) => new FakeRipple ( el ) ) ;
108
+ setupTest ( /** removeIcon */ true , rippleFactory ) ;
113
109
} ) ;
114
110
115
111
test ( 'destroy destroys icon ripples' , ( ) => {
0 commit comments