Skip to content

Commit

Permalink
rearrange test folder for dual-mode tests (js/html)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott J. Miles committed Apr 8, 2013
1 parent aec3e06 commit da9c81b
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 24 deletions.
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() {

This comment has been minimized.

Copy link
@sorvell

sorvell Apr 9, 2013

Contributor

use inName in call to suite

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

0 comments on commit da9c81b

Please sign in to comment.