test refactor

This commit is contained in:
Peter Cottle 2015-03-23 09:20:21 -07:00
parent fba7e4bb3d
commit 8709f87b4f
2 changed files with 13 additions and 8 deletions

View file

@ -1,8 +1,9 @@
var CasperHelp = {
var CasperUtils = {
getRoot: function() {
// Unfortunately this is hardcoded for now :*( cant get the path
// variable while in a casper context
// variable synchronously when running this test, and CasperJS does
// not like being started asynchronously.
return '/Users/pcottle/Dropbox/wip/learnGitBranching/';
},
@ -17,7 +18,11 @@ var CasperHelp = {
waits: {
jsMount: function() {
return this.evaluate(function() {
return document.querySelectorAll('div.BaseHelperBar').length > 0;
var hasHelper = document.querySelectorAll('div.BaseHelperBar').length > 0;
if (hasHelper) {
__utils__.echo('<<< JS mounted >>>');
}
return hasHelper;
});
},
@ -31,4 +36,4 @@ var CasperHelp = {
};
exports.CasperHelp = CasperHelp;
exports.CasperUtils = CasperUtils;

View file

@ -1,4 +1,4 @@
var CasperHelp = require('./casperHelp').CasperHelp;
var CasperUtils = require('./casperUtils').CasperUtils;
var visibleIDs = [
'commandLineHistory',
@ -18,13 +18,13 @@ var doneSelectors = [
];
casper.start(
CasperHelp.getUrlForCommands([
CasperUtils.getUrlForCommands([
'git commit',
]),
function() {
this.test.assertTitle('Learn Git Branching');
casper.waitFor(CasperHelp.waits.jsMount, function then() {
casper.waitFor(CasperUtils.waits.jsMount, function then() {
visibleIDs.forEach(function(id) {
this.test.assertVisible('#' + id);
}.bind(this));
@ -34,7 +34,7 @@ casper.start(
}.bind(this));
})
.waitFor(CasperHelp.waits.allCommandsFinished, function then() {
.waitFor(CasperUtils.waits.allCommandsFinished, function then() {
doneSelectors.forEach(function(selector) {
this.test.assertExists(selector);
}.bind(this));