-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(popover): add new awesome
popover
component
- Loading branch information
1 parent
270995d
commit 7dbefd6
Showing
25 changed files
with
1,495 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { browser, by, element } from 'protractor'; | ||
|
||
const contentTemplate = by.css('nb-card:nth-child(1) button:nth-child(1)'); | ||
const contentComponent = by.css('nb-card:nth-child(1) button:nth-child(2)'); | ||
const contentString = by.css('nb-card:nth-child(1) button:nth-child(3)'); | ||
const placementRight = by.css('nb-card:nth-child(2) button:nth-child(1)'); | ||
const placementBottom = by.css('nb-card:nth-child(2) button:nth-child(2)'); | ||
const placementTop = by.css('nb-card:nth-child(2) button:nth-child(3)'); | ||
const placementLeft = by.css('nb-card:nth-child(2) button:nth-child(4)'); | ||
const modeClick = by.css('nb-card:nth-child(4) button:nth-child(1)'); | ||
const modeHover = by.css('nb-card:nth-child(4) button:nth-child(2)'); | ||
const modeHint = by.css('nb-card:nth-child(4) button:nth-child(3)'); | ||
const popover = by.css('nb-layout > nb-popover'); | ||
|
||
describe('nb-popover', () => { | ||
|
||
beforeEach((done) => { | ||
browser.get('#/popover').then(done); | ||
}); | ||
|
||
it('render template ref', () => { | ||
element(contentTemplate).click(); | ||
const containerContent = element(popover).element(by.css('nb-card')); | ||
expect(containerContent.isPresent()).toBeTruthy(); | ||
}); | ||
|
||
it('render component ref', () => { | ||
element(contentComponent).click(); | ||
const containerContent = element(popover).element(by.css('nb-dynamic-to-add')); | ||
expect(containerContent.isPresent()).toBeTruthy(); | ||
}); | ||
|
||
it('render primitive', () => { | ||
element(contentString).click(); | ||
const containerContent = element(popover).element(by.css('div')); | ||
expect(containerContent.isPresent()).toBeTruthy(); | ||
expect(containerContent.getAttribute('class')).toEqual('primitive-popover'); | ||
expect(containerContent.getText()).toEqual('Hi, I\'m popover!'); | ||
}); | ||
|
||
it('render container with arrow', () => { | ||
element(contentTemplate).click(); | ||
const arrow = element(popover).element(by.css('span')); | ||
expect(arrow.getAttribute('class')).toEqual('arrow'); | ||
}); | ||
|
||
it('render container in the right', () => { | ||
element(placementRight).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
expect(container.getAttribute('class')).toEqual('right'); | ||
}); | ||
|
||
it('render container in the bottom', () => { | ||
element(placementBottom).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
expect(container.getAttribute('class')).toEqual('bottom'); | ||
}); | ||
|
||
it('render container in the top', () => { | ||
element(placementTop).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
expect(container.getAttribute('class')).toEqual('top'); | ||
}); | ||
|
||
it('render container in the left', () => { | ||
element(placementLeft).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
expect(container.getAttribute('class')).toEqual('left'); | ||
}); | ||
|
||
it('open popover by host click', () => { | ||
element(modeClick).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
}); | ||
|
||
it('close popover by host click', () => { | ||
element(modeClick).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
element(modeClick).click(); | ||
expect(container.isPresent()).toBeFalsy(); | ||
}); | ||
|
||
it('doesn\'t close popover by container click', () => { | ||
element(modeClick).click(); | ||
const container = element(popover); | ||
container.click(); | ||
expect(container.isPresent()).toBeTruthy(); | ||
}); | ||
|
||
it('close popover by click outside the host and container', () => { | ||
element(modeClick).click(); | ||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
browser.actions() | ||
.mouseMove(container, { x: -10, y: -10 }) | ||
.click() | ||
.perform(); | ||
expect(container.isPresent()).toBeFalsy(); | ||
}); | ||
|
||
it('open popover by hover on host', () => { | ||
browser.actions() | ||
.mouseMove(element(modeHover)) | ||
.perform(); | ||
|
||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
}); | ||
|
||
it('close popover by hover out host', () => { | ||
browser.actions() | ||
.mouseMove(element(modeHover)) | ||
.perform(); | ||
|
||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
|
||
browser.actions() | ||
.mouseMove(element(modeClick)) | ||
.perform(); | ||
|
||
expect(container.isPresent()).toBeFalsy(); | ||
}); | ||
|
||
it('doesn\'t close popover by hover on container', () => { | ||
browser.actions() | ||
.mouseMove(element(modeHover)) | ||
.perform(); | ||
|
||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
|
||
browser.actions() | ||
.mouseMove(container) | ||
.perform(); | ||
|
||
expect(container.isPresent()).toBeTruthy(); | ||
}); | ||
|
||
it('open popover by hover on host with hint', () => { | ||
browser.actions() | ||
.mouseMove(element(modeHint)) | ||
.perform(); | ||
|
||
const container = element(popover); | ||
expect(container.isPresent()).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.