update tests for menu closed event and call cancel on closePopup
This commit is contained in:
parent
14b65467d8
commit
ef7357dedc
2 changed files with 11 additions and 4 deletions
|
@ -60,6 +60,8 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
|||
}
|
||||
|
||||
void MenuViews::ClosePopupAt(int32_t window_id) {
|
||||
if (menu_runners_[window_id])
|
||||
menu_runners_[window_id]->Cancel();
|
||||
menu_runners_.erase(window_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -329,25 +329,30 @@ describe('Menu module', () => {
|
|||
let w = null
|
||||
let menu
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((done) => {
|
||||
w = new BrowserWindow({show: false, width: 200, height: 200})
|
||||
menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: '1'
|
||||
}
|
||||
])
|
||||
menu.popup(w, {x: 100, y: 100, async: true})
|
||||
menu.closePopup(w)
|
||||
|
||||
w.loadURL('data:text/html,<html>teszt</html>')
|
||||
w.webContents.on('dom-ready', () => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
return closeWindow(w).then(() => { w = null })
|
||||
})
|
||||
|
||||
it('emits closed event', () => {
|
||||
it('emits closed event', (done) => {
|
||||
menu.popup(w, {x: 100, y: 100, async: true})
|
||||
menu.on('closed', () => {
|
||||
done()
|
||||
})
|
||||
menu.closePopup(w)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue