Skip to content

Commit

Permalink
Test two levels of submenus
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed May 15, 2019
1 parent 03697a3 commit 103fd97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/vaadin-contextmenu-items-mixin.html
Expand Up @@ -157,9 +157,7 @@
subMenu.$.overlay._setParentOverlay(parent);

// Set theme attribute from parent element
if (parent.theme) {
subMenu.setAttribute('theme', parent.theme);
}
parent.theme && subMenu.setAttribute('theme', parent.theme);

let x;
content.style.minWidth = '';
Expand Down
19 changes: 11 additions & 8 deletions test/items.html
Expand Up @@ -522,19 +522,22 @@
});

it('should propagate theme attribute to the nested elements', () => {
const overlay = subMenu.$.overlay;
const listBox = overlay.querySelector('vaadin-context-menu-list-box');
const items = Array.from(listBox.querySelectorAll('vaadin-context-menu-item'));
[rootMenu, subMenu, subMenu2].forEach(subMenu => {
const overlay = subMenu.$.overlay;
const listBox = overlay.querySelector('vaadin-context-menu-list-box');
const items = Array.from(listBox.querySelectorAll('vaadin-context-menu-item'));

expect(overlay.getAttribute('theme')).to.equal('foo');
expect(listBox.getAttribute('theme')).to.equal('foo');
expect(overlay.getAttribute('theme')).to.equal('foo');
expect(listBox.getAttribute('theme')).to.equal('foo');

const itemsThemeEqualsFoo = items.filter(item => item.getAttribute('theme') !== 'foo').length === 0;
expect(itemsThemeEqualsFoo).to.be.true;
const itemsThemeEqualsFoo = items.filter(item => item.getAttribute('theme') !== 'foo').length === 0;
expect(itemsThemeEqualsFoo).to.be.true;
});
});

it('should close the submenu on theme changed', () => {
it('should close the menu and submenu on theme changed', () => {
rootMenu.setAttribute('theme', 'bar');
expect(rootMenu.opened).to.be.false;
expect(subMenu.opened).to.be.false;
expect(subMenu2.opened).to.be.false;
});
Expand Down

0 comments on commit 103fd97

Please sign in to comment.