Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring experimental test harness in from alt-test branch #85

Merged
merged 3 commits into from
Apr 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions conf/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ files = [
MOCHA_ADAPTER,
'conf/mocha.conf.js',
'node_modules/chai/chai.js',
'test/lib/test-html.js',
'platform/platform.js',
'toolkit.js',
'test/*.js',
'test/js/*.js',
{pattern: 'platform/**/*', included: false},
{pattern: 'src/*.js', included: false}
];
Expand Down Expand Up @@ -60,11 +61,14 @@ autoWatch = true;
// - PhantomJS
// - IE (only Windows)
// CLI --browsers Chrome,Firefox,Safari
browsers = ['Chrome', 'ChromeCanary', 'Firefox']
//browsers = ['ChromeCanary']
//browsers = ['ChromeCanary', 'IE'];
browsers = ['Chrome', 'ChromeCanary', 'Firefox'];
//browsers = ['Chrome', 'ChromeCanary', 'Firefox', 'IE'];

// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 5000
captureTimeout = 5000;
captureTimeout = 50000;

// Auto run tests on start (when browsers are captured) and exit
// CLI --single-run --no-single-run
Expand Down
2 changes: 1 addition & 1 deletion platform
Submodule platform updated 1 files
+1 −1 CustomElements
16 changes: 4 additions & 12 deletions test/bind-object-repeat.html → test/html/bind-object-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
<html>
<head>
<title>bind object + repeat</title>
<script>
// testing
var done = function() {
top.postMessage('ok', '*');
}
window.onerror = function(x) {
top.postMessage(x, '*');
};
</script>
<script src="../platform/platform.js"></script>
<script src="../toolkit.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../../platform/platform.js"></script>
<script src="../../toolkit.js"></script>
<script src="../lib/html-test.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
</head>
<body>
<x-bind-obj></x-bind-obj>
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 8 additions & 2 deletions test/bindProperties.js → test/js/bindProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ suite('bindProperties', function() {
});
});

htmlSuite('bindProperties-declarative', function() {
htmlTest('html/bind-object-repeat.html');
});

/*
suite('bindProperties-declarative', function() {
var assert = chai.assert;

var listener;
var magic;
var iframe;
Expand Down Expand Up @@ -68,4 +73,5 @@ suite('bindProperties-declarative', function() {
};

htmlTest('bind-object-repeat.html');
});
});
*/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions test/lib/html-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2013 The Toolkitchen Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

// if standalone
if (window.top === window) {
window.done = function() {
alert('Test Passed');
}
window.onerror = function(x) {
alert('Test FAILED: ' + x);
};
} else
// if part of a test suite
{
window.done = function() {
top.postMessage('ok', '*');
}
window.onerror = function(x) {
top.postMessage(x, '*');
};
}

45 changes: 45 additions & 0 deletions test/lib/test-html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2013 The Toolkitchen Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

(function() {
var listener, next, iframe;

function htmlSetup() {
listener = window.addEventListener("message", function(event) {
if (event.data === 'ok') {
next();
} else {
throw event.data;
}
});
iframe = document.createElement('iframe');
iframe.style.cssText = 'position: absolute; left: -9000em; width:768px; height: 1024px';
document.body.appendChild(iframe);
}

function htmlTeardown() {
window.removeEventListener(listener);
document.body.removeChild(iframe);
}

function htmlTest(src) {
test(src, function(done) {
next = done;
iframe.src = src + "?" + Math.random();
});
};

function htmlSuite(inName, inFn) {
suite('bindProperties-declarative', function() {
setup(htmlSetup);
teardown(htmlTeardown);
inFn();
});
};

window.htmlTest = htmlTest;
window.htmlSuite = htmlSuite;
})();
21 changes: 11 additions & 10 deletions test/index.html → test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="lib/test-html.js"></script>
<!-- -->
<script src="../Platform/platform.js"></script>
<script src="../toolkit.js"></script>
Expand All @@ -21,16 +22,16 @@
<script>
mocha.setup({ui: 'tdd'});
</script>
<!-- -->
<script src="lang.js"></script>
<script src="marshall.js"></script>
<script src="oop.js"></script>
<script src="bindProperties.js"></script>
<script src="bindMDV.js"></script>
<script src="attrs.js"></script>
<script src="register.js"></script>
<script src="events.js"></script>
<!-- -->
<!-- -->
<script src="js/lang.js"></script>
<script src="js/marshall.js"></script>
<script src="js/oop.js"></script>
<script src="js/bindProperties.js"></script>
<script src="js/bindMDV.js"></script>
<script src="js/attrs.js"></script>
<script src="js/register.js"></script>
<script src="js/events.js"></script>
<!-- -->
<script>
mocha.run();
</script>
Expand Down