spec: Remove annoying outputs from savePage test

This commit is contained in:
Cheng Zhao 2016-01-13 17:12:47 +08:00
parent c10c419f1d
commit 60d44b3b04
3 changed files with 26 additions and 18 deletions

View file

@ -455,31 +455,39 @@ describe('browser-window module', function() {
}); });
}); });
}); });
describe('save page', function() {
var savePageCssPath, savePageDir, savePageHtmlPath, savePageJsPath; describe('savePage method', function() {
savePageDir = path.join(fixtures, 'save_page'); const savePageDir = path.join(fixtures, 'save_page');
savePageHtmlPath = path.join(savePageDir, 'save_page.html'); const savePageHtmlPath = path.join(savePageDir, 'save_page.html');
savePageJsPath = path.join(savePageDir, 'save_page_files', 'test.js'); const savePageJsPath = path.join(savePageDir, 'save_page_files', 'test.js');
savePageCssPath = path.join(savePageDir, 'save_page_files', 'test.css'); const savePageCssPath = path.join(savePageDir, 'save_page_files', 'test.css');
return it('should save page', function(done) {
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() { 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.equal(error, null);
assert(fs.existsSync(savePageHtmlPath)); assert(fs.existsSync(savePageHtmlPath));
assert(fs.existsSync(savePageJsPath)); assert(fs.existsSync(savePageJsPath));
assert(fs.existsSync(savePageCssPath)); assert(fs.existsSync(savePageCssPath));
fs.unlinkSync(savePageCssPath); done();
fs.unlinkSync(savePageJsPath);
fs.unlinkSync(savePageHtmlPath);
fs.rmdirSync(path.join(savePageDir, 'save_page_files'));
fs.rmdirSync(savePageDir);
return 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() { return it('should create a window with default size (800x600)', function() {
var size; var size;
w.destroy(); w.destroy();

View file

@ -1,6 +1,6 @@
<html> <html>
<script type="text/javascript" src="test.js"></script> <script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test.css"></script> <link href="test.css" rel="stylesheet">
<body> <body>
</body> </body>
</html> </html>

View file

@ -1 +1 @@
console.log('save_page'); // do nothing