DRY up specs
authorKevin Sawicki <kevinsawicki@gmail.com>
Tue, 17 May 2016 21:59:33 +0000 (14:59 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 17 May 2016 21:59:33 +0000 (14:59 -0700)
spec/api-browser-window-spec.js

index 46fc6a34c89e616e8034d9f5319981c7f7538f59..6178d7639848674fa563baf570fb02b77d4cdae6 100644 (file)
@@ -825,25 +825,29 @@ describe('browser-window module', function () {
 
   describe('dev tool extensions', function () {
     describe('BrowserWindow.addDevToolsExtension', function () {
+      this.timeout(10000)
+
       beforeEach(function () {
         BrowserWindow.removeDevToolsExtension('foo')
+
+        var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
+        BrowserWindow.addDevToolsExtension(extensionPath)
+
+        w.webContents.on('devtools-opened', () => {
+          var inputEventIntervalId = setInterval(function () {
+            if (w && w.devToolsWebContents) {
+              w.devToolsWebContents.sendInputEvent({type: 'keyDown', keyCode:'[', modifiers: ['meta']})
+            } else {
+              clearInterval(inputEventIntervalId)
+            }
+          }, 200)
+        })
+
+        w.loadURL('about:blank')
       })
 
       describe('when the devtools is docked', function () {
         it('creates the extension', function (done) {
-          var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
-          BrowserWindow.addDevToolsExtension(extensionPath)
-
-          w.webContents.on('devtools-opened', () => {
-            var inputEventIntervalId = setInterval(function () {
-              if (w && w.devToolsWebContents) {
-                w.devToolsWebContents.sendInputEvent({type: 'keyDown', keyCode:'[', modifiers: ['meta']})
-              } else {
-                clearInterval(inputEventIntervalId)
-              }
-            }, 250)
-          })
-          w.loadURL('about:blank')
           w.webContents.openDevTools({mode: 'bottom'})
 
           ipcMain.once('answer', function (event, message) {
@@ -855,19 +859,6 @@ describe('browser-window module', function () {
 
       describe('when the devtools is undocked', function () {
         it('creates the extension', function (done) {
-          var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
-          BrowserWindow.addDevToolsExtension(extensionPath)
-
-          w.webContents.on('devtools-opened', () => {
-            var inputEventIntervalId = setInterval(function () {
-              if (w && w.devToolsWebContents) {
-                w.devToolsWebContents.sendInputEvent({type: 'keyDown', keyCode:'[', modifiers: ['meta']})
-              } else {
-                clearInterval(inputEventIntervalId)
-              }
-            }, 250)
-          })
-          w.loadURL('about:blank')
           w.webContents.openDevTools({mode: 'undocked'})
 
           ipcMain.once('answer', function (event, message) {