|
| 1 | +import { browser, by, element } from 'protractor'; |
| 2 | + |
| 3 | +const withContextMenu = by.css('nb-card:nth-child(1) nb-user:nth-child(1)'); |
| 4 | +const popover = by.css('nb-layout > nb-popover'); |
| 5 | + |
| 6 | +describe('nb-context-menu', () => { |
| 7 | + |
| 8 | + beforeEach((done) => { |
| 9 | + browser.get('#/context-menu').then(done); |
| 10 | + }); |
| 11 | + |
| 12 | + it('have to be opened by click', () => { |
| 13 | + element(withContextMenu).click(); |
| 14 | + const containerContent = element(popover).element(by.css('nb-menu > ul')); |
| 15 | + expect(containerContent.isPresent()).toBeTruthy(); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should have two menu items', () => { |
| 19 | + element(withContextMenu).click(); |
| 20 | + const menuItems = element(popover).all(by.css('nb-menu > ul > li')); |
| 21 | + |
| 22 | + expect(menuItems.count()).toEqual(2); |
| 23 | + }); |
| 24 | + |
| 25 | + it('have to open user page after click on first item', () => { |
| 26 | + element(withContextMenu).click(); |
| 27 | + const menuItems = element(popover).all(by.css('nb-menu > ul > li')); |
| 28 | + menuItems.get(0).click(); |
| 29 | + |
| 30 | + expect(browser.getCurrentUrl().then(it => it.split('#/')[1])).toEqual('user'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('have to open popover page after click on second item', () => { |
| 34 | + element(withContextMenu).click(); |
| 35 | + const menuItems = element(popover).all(by.css('nb-menu > ul > li')); |
| 36 | + menuItems.get(1).click(); |
| 37 | + |
| 38 | + expect(browser.getCurrentUrl().then(it => it.split('#/')[1])).toEqual('popover'); |
| 39 | + }); |
| 40 | +}); |
0 commit comments