Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Correct broken list structure on list actions #333

Merged
merged 13 commits into from
Feb 27, 2012
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ the python instructions, open up your browser to

All green means you're good to go.

4. Want to run the tests from the command line? You can do that to! Just install
[PhantomJS](http://www.phantomjs.org/) and then (if you used the http server
from step 2) call:

$ build/phantomjs_test.sh localhost:8000/test/unit

### Building WYMeditor

1. Get a copy of the source using git:
Expand Down
4 changes: 4 additions & 0 deletions build/phantomjs_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
UNIT_TEST_URL=http://$1/index.html?tapOutput=true;
BUILD_DIR="`dirname \"$0\"`"
phantomjs $BUILD_DIR/run_qunit.js $UNIT_TEST_URL
81 changes: 81 additions & 0 deletions build/run_qunit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx Callback that evaluates to a boolean,
* @param onReady Callback to execute on succesful completion
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
*/
function waitFor(testFx, onReady, timeOutMillis) {
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3001, //< Default Max Timout is 3s
start = new Date().getTime(),
condition = false,
interval = setInterval(function() {
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
// If not time-out yet and condition not yet fulfilled
condition = testFx();
} else {
if(!condition) {
// If condition still not fulfilled (timeout but condition is 'false')
console.log("# 'waitFor()' timeout");
phantom.exit(1);
} else {
// Condition fulfilled (timeout and/or condition is 'true')
// console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
onReady(); //< Do what it's supposed to do once the condition is fulfilled
clearInterval(interval); //< Stop this interval
}
}
}, 100); //< repeat check every 100ms
}


if (phantom.args.length === 0 || phantom.args.length > 2) {
console.log('Usage: run-qunit.js URL');
phantom.exit(1);
}

var page = new WebPage();

// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
console.log(msg);
};

// Open the URL of the first argument, wait for the results to finish and then output a summary.
// Exists with 0 on success, 1 with failures, 2 with a phantomjs error
page.open(phantom.args[0], function(status){
if (status !== "success") {
console.log("Unable to access network");
phantom.exit(2);
} else {
waitFor(
function(){
return page.evaluate(function(){
var el = document.getElementById('qunit-testresult');
if (el && el.innerText.match('completed')) {
return true;
}
return false;
});
},
function(){
// Output the summary and return 1 if it was an all-pass
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should read 'return 0 if it was an all-pass'

var returnCode = page.evaluate(function() {
var failString = '';
var results = document.getElementById('qunit-testresult');
console.log(results.innerText);
try {
failString = el.getElementsByClassName('failed')[0].innerHTML;
} catch (e) { }
if (parseInt(failString, 10) > 0) {
return 1; // Failures
}
return 0; // All pass
});
phantom.exit(returnCode);
},
15000 // 15 seconds timeout
);
}
});
8 changes: 8 additions & 0 deletions src/test/unit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"../../wymeditor/plugins/table/jquery.wymeditor.table.js",

"qunit.js",
"qunit-tap.js",

// Test files
"utils.js",
Expand All @@ -67,6 +68,13 @@
urlParams['jquery']
);
</script>
<script>
if (urlParams.tapOutput) {
// Only provide tap output when ?tapOutput=true
// When running via phantomJS, use that URL
qunitTap(QUnit, function() { console.log.apply(console, arguments); }, {noPlan: true});
}
</script>
</head>

<body>
Expand Down
Loading