Skip to content

Commit

Permalink
WebView, feat: add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Aug 9, 2017
1 parent 63e8f87 commit 7dff994
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/gui_files/gui1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("gui").open("fs:" + __dirname + "/t1.html").wait();
3 changes: 3 additions & 0 deletions test/gui_files/gui2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require("gui").open("fs:" + __dirname + "/t1.html", {
debug: false
}).wait();
13 changes: 13 additions & 0 deletions test/gui_files/t1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>

<script>
external.postMessage("test");
setTimeout(function () {
window.close();
}, 1);
console.log("this is.a log");
console.warn("this is.a warn");
console.log(_not_exists)
</script>

</html>
15 changes: 15 additions & 0 deletions test/gui_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test.setup();
var test_util = require('./test_util');

var os = require("os");
var path = require("path");

var win = process.platform == 'win32';

Expand Down Expand Up @@ -82,6 +83,20 @@ if (win) {
assert.equal(closed, true);
assert.equal(cnt, 2);
});

it("log", () => {
var p = process.open(process.execPath, [path.join(__dirname, 'gui_files', 'gui1.js')]);
var r = p.readLines();
assert.equal(r[0], 'this is.a log');
assert.equal(r[1], '\u001b[0;33mthis is.a warn\u001b[0m');
assert.equal(r[2].substr(0, 21), '\x1b[1;31mWebView Error:');
});

it("debug", () => {
var p = process.open(process.execPath, [path.join(__dirname, 'gui_files', 'gui2.js')]);
var r = p.readLines();
assert.equal(r.length, 0);
});
});
}

Expand Down

0 comments on commit 7dff994

Please sign in to comment.