Skip to content

Commit

Permalink
Merge more testing coverage from henrikingo fork
Browse files Browse the repository at this point in the history
* core_tests.js and navigation_tests.js have more tests
* qunit_test_runner.html runs QUnit in a browser (without karma) and
  provides a generic iframe based platform to test different  presentations.
* copy qunit.js and syn.js into the repo. This allows qunit_test_runner.html
  to work without any dependency on node/npm. (Karma obviously does need them.)
* Move jscs cli option to .jscsrc instead
  • Loading branch information
henrikingo committed Sep 16, 2017
1 parent 0b4bd08 commit 7aaea7f
Show file tree
Hide file tree
Showing 12 changed files with 7,536 additions and 181 deletions.
5 changes: 5 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"preset": "jquery",
// Since we check quotemarks already in jshint, this can be turned off
"validateQuoteMarks": false
}
37 changes: 31 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ module.exports = function( config ) {
// Frameworks to use
frameworks: [ "qunit" ],

proxies : {
'/test/' : '/base/test/',
'/js/' : '/base/js/'
},

// List of files / patterns to load in the browser
files: [
"test/bootstrap.js",
"js/impress.js",
"test/core_tests.js"
// The QUnit tests
"test/helpers.js",
"test/core_tests.js",
"test/navigation_tests.js",
// Presentation files, for the iframe
//"test/core_tests_presentation.html"
//{pattern: "test/core_tests_presentation.html", watched: true, served: true, included: false}
{pattern: "test/*.html", watched: true, served: true, included: false},
{pattern: "test/plugins/*/*.html", watched: true, served: true, included: false},
// JS files for iframe
{pattern: "js/impress.js", watched: true, served: true, included: false},
{pattern: "test/syn/syn.js", watched: true, served: true, included: false}
],

// List of files to exclude
Expand Down Expand Up @@ -43,11 +57,22 @@ module.exports = function( config ) {
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: [ "Chrome" ],
//browsers: [ "Chrome" ],
//browsers: [ "Firefox" ],
browsers: [ "Chrome", "Firefox" ],

// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
client: {
clearContext: false,
qunit: {
showUI: true,
testTimeout: 120*1000
}
},

// If browser does not capture, or produce output, in given timeout [ms], kill it
captureTimeout: 60*1000,
browserNoActivityTimeout: 60*1000,

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@
"url": "https://github.com/bartaz/impress.js/issues"
},
"scripts": {
"lint": "jshint js/impress.js *.js test/bootstrap.js && jscs js/impress.js *.js test/bootstrap.js --preset=jquery",
"lint": "jshint js/impress.js test/*.js && jscs js/impress.js test/*.js",
"test": "karma start --single-run",
"test:dev": "karma start",
"test:sauce": "karma start karma.conf-sauce.js"
},
"devDependencies": {
"chrome": "0.1.0",
"firefox": "*",
"jscs": "2.11.0",
"jshint": "2.9.1",
"karma": "0.13.22",
"karma-chrome-launcher": "1.0.1",
"karma-cli": "1.0.0",
"karma-firefox-launcher": "~0.1",
"karma-qunit": "1.0.0",
"karma-sauce-launcher": "1.0.0",
"qunitjs": "2.0.0-rc1"
Expand Down
26 changes: 26 additions & 0 deletions qunit_test_runner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<!--
Copyright 2016 Henrik Ingo (@henrikingo)
Released under the MIT license. See LICENSE file.
-->
<html>
<head>
<meta charset="utf-8">
<title>QUnit tests for impress.js</title>
<link rel="stylesheet" href="test/qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>

<div id="qunit-fixture"></div>

<script src="test/qunit/qunit.js"></script>
<!-- The QUnit tests. -->
<script src="test/helpers.js"></script>
<!-- Core tests -->
<script src="test/core_tests.js"></script>
<!-- Plugins -->
<script src="test/navigation_tests.js"></script>

</body>
</html>
33 changes: 23 additions & 10 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
/*jshint browser:true */

var root = document.createElement( "div" );
root.innerHTML = [
"<div id='impress'>",
" <div class='step' data-x='-1000' data-y='0'>First slide</div>",
" <div class='step' data-x='-800' data-y='0'>Second slide</div>",
" <div class='step' data-x='-600' data-y='0'>Third slide</div>",
" <div class='step' data-x='-400' data-y='0'>Fourth slide</div>",
"</div>"
].join( "" );
document.body.appendChild( root );
// TODO: This is the bootstrap file for *karma*. Poorly named (since karma is
// only one option, in this repo) but keeping the same name now to avoid
// unnecessary deviation with upstream.
// If you just want to run the tests locally, you can open test/index.html in Firefox.

// That's annoying: karma-qunit doesn't provide the qunit-fixture element
// https://github.com/karma-runner/karma-qunit/issues/18

// This file contains so much HTML, that we will just respectfully disagree about js
/* jshint quotmark:single */
/* global document */

var fix = document.createElement( 'div' );
fix.id = 'qunit-fixture';
fix.innerHTML = [
'\n',
' <iframe id="presentation-iframe"\n',
' src="SET THIS IN YOUR QUNIT TESTS"\n',
' width="595" height="485"\n',
' frameborder="0" marginwidth="0" marginheight="0" scrolling="no"\n',
' style="border:1px solid #CCC; max-width: 100%;">\n',
' </iframe>'
].join( '' );
Loading

0 comments on commit 7aaea7f

Please sign in to comment.