Browse Source

some code cleanup

gemini
Alexander Wunschik 7 years ago
parent
commit
dbb764299c
4 changed files with 40 additions and 39 deletions
  1. +36
    -14
      gulpfile.js
  2. +3
    -3
      package.json
  3. BIN
      test/gemini/screens/timline/BasicExample/plain/PhantomJS.png
  4. +1
    -22
      test/gemini/tests/timeline/BasicExample/index.html

+ 36
- 14
gulpfile.js View File

@ -118,26 +118,37 @@ function handleCompilerCallback(err, stats) {
}
}
function startDevWebserver(cb) {
return gulp.src('./').pipe(webserver({
function startDevWebserver(options, cb) {
var opt = options || {};
return gulp.src('./').pipe(webserver(Object.assign(opt, {
path: '/',
port: geminiConfig.webserver.port
}));
})));
}
gulp.task('gemini-webserver', function(cb) {
startDevWebserver(cb);
// Starts a static webserver that serve files from the root-dir of the project
// during development. This is also used for gemini-testing.
gulp.task('webserver', function(cb) {
startDevWebserver({
livereload: true,
directoryListing: true,
open: true
}, cb);
});
function runGemini(mode, cb) {
var completed = false;
var hasError = false;
// start development webserver to server the test-files
var server = startDevWebserver();
// start phantomjs in webdriver mode
var phantomjsProcess = spawn('phantomjs', [
'--webdriver=' + geminiConfig.phantomjs.port
]);
var completed = false;
var hasError = false;
// read output from the phantomjs process
phantomjsProcess.stdout.on('data', function(data) {
if (data.toString().indexOf('running on port') >= 0) {
gutil.log("Started phantomjs webdriver");
@ -165,35 +176,46 @@ function runGemini(mode, cb) {
geminiProcess.on('close', function(code) {
completed = true;
phantomjsProcess.kill();
server.emit('kill');
});
}
});
// Log all error output from the phantomjs process to the console
phantomjsProcess.stderr.on('data', function(data) {
gutil.log(gutil.colors.red(data));
});
// Cleanup after phantomjs closes
phantomjsProcess.on('close', function(code) {
gutil.log("Phantomjs webdriver stopped");
if (code && !completed) {
// phantomjs closed with an error
server.emit('kill');
return cb(new Error('✘ phantomjs failed with code: ' + code + '\n' +
'Check that port ' + geminiConfig.phantomjs.port +
' is free and that there are no other ' +
'instances of phantomjs running. (`killall phantomjs`)'));
}
gutil.log("Stoped phantomjs webdriver");
if (hasError) {
gutil.log("Opening report in webbrowser");
opn(geminiConfig.gemini.reports);
// The tests returned with an error. Show the report. Keep dev-webserver running for debugging.
gutil.log(gutil.colors.red("Opening error-report in webbrowser"));
opn(geminiConfig.gemini.reports + 'index.html');
} else {
// The tests returned no error. Kill the dev-webserver and exit
server.emit('kill');
cb();
}
cb();
});
}
// Update the screenshots. Do this everytime you introduced a new test or introduced a major change.
gulp.task('gemini-update', function(cb) {
runGemini('update', cb);
});
// Test the current (dist) version against the existing screenshots.
gulp.task('gemini-test', function(cb) {
runGemini('test', cb);
});

+ 3
- 3
package.json View File

@ -23,10 +23,10 @@
],
"main": "./dist/vis.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register",
"gemini": "gemini",
"gemini-tests": "gulp gemini-tests",
"gulp": "gulp",
"test": "mocha --compilers js:babel-core/register",
"gemini-update": "gulp gemini-update",
"gemini-test": "gulp gemini-test",
"build": "gulp",
"lint": "eslint lib",
"watch": "gulp watch",

BIN
test/gemini/screens/timline/BasicExample/plain/PhantomJS.png View File

Before After
Width: 1350  |  Height: 150  |  Size: 11 KiB Width: 1350  |  Height: 150  |  Size: 11 KiB

+ 1
- 22
test/gemini/tests/timeline/BasicExample/index.html View File

@ -1,31 +1,14 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Timeline | Basic demo</title>
<style type="text/css">
body, html {
font-family: sans-serif;
}
</style>
<title>Timeline | BasicExample</title>
<script src="/dist/vis.js"></script>
<link href="/dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>
A basic timeline. You can move and zoom the timeline, and select items.
</p>
<div id="timeline" class="gemini-test-timeline"></div>
<script type="text/javascript">
// DOM element where the Timeline will be attached
var container = document.getElementById('timeline');
// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet([
{id: 1, content: 'item 1', start: '2014-04-20'},
{id: 2, content: 'item 2', start: '2014-04-14'},
@ -34,11 +17,7 @@
{id: 5, content: 'item 5', start: '2014-04-25'},
{id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
]);
// Configuration for the Timeline
var options = {};
// Create a Timeline
var timeline = new vis.Timeline(container, items, options);
</script>
</body>

Loading…
Cancel
Save