Add spec for async Menu.popup
authorKevin Sawicki <kevinsawicki@gmail.com>
Thu, 16 Feb 2017 18:58:12 +0000 (10:58 -0800)
committerKevin Sawicki <kevinsawicki@gmail.com>
Wed, 22 Feb 2017 18:30:28 +0000 (10:30 -0800)
spec/api-menu-spec.js

index 0c3cb50..176f1ea 100644 (file)
@@ -1,7 +1,8 @@
 const assert = require('assert')
 
 const {ipcRenderer, remote} = require('electron')
-const {Menu, MenuItem} = remote
+const {BrowserWindow, Menu, MenuItem} = remote
+const {closeWindow} = require('./window-helpers')
 
 describe('menu module', function () {
   describe('Menu.buildFromTemplate', function () {
@@ -216,6 +217,30 @@ describe('menu module', function () {
     })
   })
 
+  describe('Menu.popup', function () {
+    let w = null
+
+    afterEach(function () {
+      return closeWindow(w).then(function () { w = null })
+    })
+
+    describe('when called with async: true', function () {
+      it('returns immediately', function () {
+        w = new BrowserWindow({show: false, width: 200, height: 200})
+        const menu = Menu.buildFromTemplate([
+          {
+            label: '1'
+          }, {
+            label: '2'
+          }, {
+            label: '3'
+          }
+        ])
+        menu.popup(w, {x: 100, y: 100, async: true})
+        menu.closePopup(w)
+      })
+    })
+  })
   describe('MenuItem.click', function () {
     it('should be called with the item object passed', function (done) {
       var menu = Menu.buildFromTemplate([