Skip to content

Commit

Permalink
feat(menu): add tests for hidden menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
mishkolesnikov committed Mar 26, 2018
1 parent 72ea569 commit e0bfe5f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
11 changes: 10 additions & 1 deletion e2e/menu.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const menu333 = by.css('#menu-first ul li:nth-child(4) ul li:nth-child(3) ul li:
const newMenu = by.css('#menu-first ul li:nth-child(5) a');
const addButton = by.css('#addBtn');
const homeButton = by.css('#homeBtn');

const hiddenMenuItem = by.css('#menu-second ul li:nth-child(3)');
const hiddenSubmenuItem = by.css('#menu-second ul li:nth-child(2) ul li:nth-child(2)');
const waitTime = 20 * 1000;

const sidebarMenu31 = by.css('#menu-sidebar ul li:nth-child(4) ul li:nth-child(1) > a > span');
Expand Down Expand Up @@ -276,4 +277,12 @@ describe('nb-menu', () => {
expect(browser.getCurrentUrl()).toContain('#/menu/1');
});
});

it('hidden menu item should not be present', () => {
expect(element(hiddenMenuItem).isPresent()).toBe(false);
});

it('hidden submenu item should not be present', () => {
expect(element(hiddenSubmenuItem).isPresent()).toBeFalsy()
});
});
47 changes: 37 additions & 10 deletions src/app/menu-test/menu-test.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export class NbMenuItem4Component { }
<button class="btn btn-primary" id="homeBtn" (click)="navigateHome()">Home</button>
</nb-card-body>
</nb-card>
<nb-card size="xxlarge">
<nb-card-body>
<nb-menu id="menu-second" tag="secondMenu" [items]="menuItems1"></nb-menu>
</nb-card-body>
</nb-card>
</nb-layout-column>
</nb-layout>
`,
Expand All @@ -119,6 +124,28 @@ export class NbMenuTestComponent implements OnInit, OnDestroy {
},
];

menuItems1 = [
{
title: 'Menu #1',
},
{
title: 'Menu #2',
children: [
{
title: 'Menu #2.1',
},
{
title: 'Hidden Submenu Item',
hidden: true,
},
],
},
{
title: 'Hidden Menu Item',
hidden: true,
},
];

private alive: boolean = true;

constructor(private menuService: NbMenuService) { }
Expand Down Expand Up @@ -180,17 +207,17 @@ export class NbMenuTestComponent implements OnInit, OnDestroy {
],
'firstMenu',
);
}
}

ngOnDestroy() {
this.alive = false;
}
ngOnDestroy() {
this.alive = false;
}

addMenuItem() {
this.menuService.addItems([{ title: 'New Menu Item' }], 'firstMenu');
}
addMenuItem() {
this.menuService.addItems([{ title: 'New Menu Item' }], 'firstMenu');
}

navigateHome() {
this.menuService.navigateHome('firstMenu');
}
navigateHome() {
this.menuService.navigateHome('firstMenu');
}
}

0 comments on commit e0bfe5f

Please sign in to comment.