From 60d44b3b045902aa66237af5730e94f09c91ae28 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 13 Jan 2016 17:12:47 +0800 Subject: [PATCH] spec: Remove annoying outputs from savePage test --- spec/api-browser-window-spec.js | 40 ++++++++++++++---------- spec/fixtures/pages/save_page/index.html | 2 +- spec/fixtures/pages/save_page/test.js | 2 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 432c9a739cd..50a98ed38ce 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -455,31 +455,39 @@ describe('browser-window module', function() { }); }); }); - describe('save page', function() { - var savePageCssPath, savePageDir, savePageHtmlPath, savePageJsPath; - savePageDir = path.join(fixtures, 'save_page'); - savePageHtmlPath = path.join(savePageDir, 'save_page.html'); - savePageJsPath = path.join(savePageDir, 'save_page_files', 'test.js'); - savePageCssPath = path.join(savePageDir, 'save_page_files', 'test.css'); - return it('should save page', function(done) { + + describe('savePage method', function() { + const savePageDir = path.join(fixtures, 'save_page'); + const savePageHtmlPath = path.join(savePageDir, 'save_page.html'); + const savePageJsPath = path.join(savePageDir, 'save_page_files', 'test.js'); + const savePageCssPath = path.join(savePageDir, 'save_page_files', 'test.css'); + + after(function() { + try { + fs.unlinkSync(savePageCssPath); + fs.unlinkSync(savePageJsPath); + fs.unlinkSync(savePageHtmlPath); + fs.rmdirSync(path.join(savePageDir, 'save_page_files')); + fs.rmdirSync(savePageDir); + } catch (e) { + } + }); + + it('should save page to disk', function(done) { w.webContents.on('did-finish-load', function() { - return w.webContents.savePage(savePageHtmlPath, 'HTMLComplete', function(error) { + w.webContents.savePage(savePageHtmlPath, 'HTMLComplete', function(error) { assert.equal(error, null); assert(fs.existsSync(savePageHtmlPath)); assert(fs.existsSync(savePageJsPath)); assert(fs.existsSync(savePageCssPath)); - fs.unlinkSync(savePageCssPath); - fs.unlinkSync(savePageJsPath); - fs.unlinkSync(savePageHtmlPath); - fs.rmdirSync(path.join(savePageDir, 'save_page_files')); - fs.rmdirSync(savePageDir); - return done(); + done(); }); }); - return w.loadURL("file://" + fixtures + "/pages/save_page/index.html"); + w.loadURL("file://" + fixtures + "/pages/save_page/index.html"); }); }); - return describe('BrowserWindow options argument is optional', function() { + + describe('BrowserWindow options argument is optional', function() { return it('should create a window with default size (800x600)', function() { var size; w.destroy(); diff --git a/spec/fixtures/pages/save_page/index.html b/spec/fixtures/pages/save_page/index.html index 829233bb86f..61445bce23d 100644 --- a/spec/fixtures/pages/save_page/index.html +++ b/spec/fixtures/pages/save_page/index.html @@ -1,6 +1,6 @@ - + diff --git a/spec/fixtures/pages/save_page/test.js b/spec/fixtures/pages/save_page/test.js index 3d79457383f..c6035e5e3f3 100644 --- a/spec/fixtures/pages/save_page/test.js +++ b/spec/fixtures/pages/save_page/test.js @@ -1 +1 @@ -console.log('save_page'); +// do nothing