Browse Source

update debugger spec

Shelley Vohr 7 years ago
parent
commit
83a290a411
1 changed files with 28 additions and 30 deletions
  1. 28 30
      spec/api-debugger-spec.js

+ 28 - 30
spec/api-debugger-spec.js

@@ -4,11 +4,11 @@ const path = require('path')
 const {closeWindow} = require('./window-helpers')
 const BrowserWindow = require('electron').remote.BrowserWindow
 
-describe('debugger module', function () {
-  var fixtures = path.resolve(__dirname, 'fixtures')
-  var w = null
+describe.only('debugger module', () => {
+  const fixtures = path.resolve(__dirname, 'fixtures')
+  let w = null
 
-  beforeEach(function () {
+  beforeEach(() => {
     w = new BrowserWindow({
       show: false,
       width: 400,
@@ -16,13 +16,11 @@ describe('debugger module', function () {
     })
   })
 
-  afterEach(function () {
-    return closeWindow(w).then(function () { w = null })
-  })
+  afterEach(() => closeWindow(w).then(() => { w = null }))
 
-  describe('debugger.attach', function () {
-    it('fails when devtools is already open', function (done) {
-      w.webContents.on('did-finish-load', function () {
+  describe('debugger.attach', () => {
+    it('fails when devtools is already open', (done) => {
+      w.webContents.on('did-finish-load', () => {
         w.webContents.openDevTools()
         try {
           w.webContents.debugger.attach()
@@ -31,10 +29,10 @@ describe('debugger module', function () {
           done()
         }
       })
-      w.webContents.loadURL('file://' + path.join(fixtures, 'pages', 'a.html'))
+      w.webContents.loadURL(`file://${path.join(fixtures, 'pages', 'a.html')}`)
     })
 
-    it('fails when protocol version is not supported', function (done) {
+    it('fails when protocol version is not supported', (done) => {
       try {
         w.webContents.debugger.attach('2.0')
       } catch (err) {
@@ -43,20 +41,20 @@ describe('debugger module', function () {
       }
     })
 
-    it('attaches when no protocol version is specified', function (done) {
+    it('attaches when no protocol version is specified', (done) => {
       try {
         w.webContents.debugger.attach()
       } catch (err) {
-        done('unexpected error : ' + err)
+        done(`unexpected error : ${err}`)
       }
       assert(w.webContents.debugger.isAttached())
       done()
     })
   })
 
-  describe('debugger.detach', function () {
-    it('fires detach event', function (done) {
-      w.webContents.debugger.on('detach', function (e, reason) {
+  describe('debugger.detach', () => {
+    it('fires detach event', (done) => {
+      w.webContents.debugger.on('detach', (e, reason) => {
         assert.equal(reason, 'target closed')
         assert(!w.webContents.debugger.isAttached())
         done()
@@ -64,23 +62,23 @@ describe('debugger module', function () {
       try {
         w.webContents.debugger.attach()
       } catch (err) {
-        done('unexpected error : ' + err)
+        done(`unexpected error : ${err}`)
       }
       w.webContents.debugger.detach()
     })
   })
 
-  describe('debugger.sendCommand', function () {
+  describe('debugger.sendCommand', () => {
     let server
 
-    afterEach(function () {
+    afterEach(() => {
       if (server != null) {
         server.close()
         server = null
       }
     })
 
-    it('retuns response', function (done) {
+    it('retuns response', (done) => {
       w.webContents.loadURL('about:blank')
       try {
         w.webContents.debugger.attach()
@@ -100,9 +98,9 @@ describe('debugger module', function () {
       w.webContents.debugger.sendCommand('Runtime.evaluate', params, callback)
     })
 
-    it('fires message event', function (done) {
-      var url = process.platform !== 'win32'
-        ? 'file://' + path.join(fixtures, 'pages', 'a.html')
+    it('fires message event', (done) => {
+      const url = process.platform !== 'win32'
+        ? `file://${path.join(fixtures, 'pages', 'a.html')}`
         : 'file:///' + path.join(fixtures, 'pages', 'a.html').replace(/\\/g, '/')
       w.webContents.loadURL(url)
       try {
@@ -110,7 +108,7 @@ describe('debugger module', function () {
       } catch (err) {
         done('unexpected error : ' + err)
       }
-      w.webContents.debugger.on('message', function (e, method, params) {
+      w.webContents.debugger.on('message', (e, method, params) => {
         if (method === 'Console.messageAdded') {
           assert.equal(params.message.level, 'log')
           assert.equal(params.message.url, url)
@@ -122,25 +120,25 @@ describe('debugger module', function () {
       w.webContents.debugger.sendCommand('Console.enable')
     })
 
-    it('returns error message when command fails', function (done) {
+    it('returns error message when command fails', (done) => {
       w.webContents.loadURL('about:blank')
       try {
         w.webContents.debugger.attach()
       } catch (err) {
-        done('unexpected error : ' + err)
+        done(`unexpected error : ${err}`)
       }
-      w.webContents.debugger.sendCommand('Test', function (err) {
+      w.webContents.debugger.sendCommand('Test', (err) => {
         assert.equal(err.message, "'Test' wasn't found")
         w.webContents.debugger.detach()
         done()
       })
     })
 
-    it('handles invalid unicode characters in message', function (done) {
+    it('handles invalid unicode characters in message', (done) => {
       try {
         w.webContents.debugger.attach()
       } catch (err) {
-        done('unexpected error : ' + err)
+        done(`unexpected error : ${err}`)
       }
 
       w.webContents.debugger.on('message', (event, method, params) => {