mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-06 04:34:29 +02:00
more test DSL
This commit is contained in:
parent
8709f87b4f
commit
27ec708cc2
2 changed files with 52 additions and 18 deletions
|
@ -15,6 +15,44 @@ var CasperUtils = {
|
|||
return this.getUrl() + '&command=' + commands.join(';');
|
||||
},
|
||||
|
||||
testDone: function() {
|
||||
this.test.done();
|
||||
},
|
||||
|
||||
multiAssert: function() {
|
||||
// Copy the args into a variable we can reference inside
|
||||
// our closure.
|
||||
var asserts = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
asserts.push(arguments[i]);
|
||||
}
|
||||
|
||||
return function then() {
|
||||
for (var i = 0; i < asserts.length; i++) {
|
||||
var assert = asserts[i];
|
||||
assert.bind(this)();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
asserts: {
|
||||
visibleIDs: function(visibleIDs) {
|
||||
return function then() {
|
||||
visibleIDs.forEach(function(id) {
|
||||
this.test.assertVisible('#' + id);
|
||||
}.bind(this));
|
||||
};
|
||||
},
|
||||
|
||||
visibleSelectors: function(selectors) {
|
||||
return function then() {
|
||||
selectors.forEach(function(selector) {
|
||||
this.test.assertExists(selector);
|
||||
}.bind(this));
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
waits: {
|
||||
jsMount: function() {
|
||||
return this.evaluate(function() {
|
||||
|
|
|
@ -24,25 +24,21 @@ casper.start(
|
|||
function() {
|
||||
this.test.assertTitle('Learn Git Branching');
|
||||
|
||||
casper.waitFor(CasperUtils.waits.jsMount, function then() {
|
||||
visibleIDs.forEach(function(id) {
|
||||
this.test.assertVisible('#' + id);
|
||||
}.bind(this));
|
||||
casper.waitFor(
|
||||
CasperUtils.waits.jsMount
|
||||
)
|
||||
|
||||
selectors.forEach(function(selector) {
|
||||
this.test.assertExists(selector);
|
||||
}.bind(this));
|
||||
.then(CasperUtils.multiAssert(
|
||||
CasperUtils.asserts.visibleIDs(visibleIDs),
|
||||
CasperUtils.asserts.visibleSelectors(selectors)
|
||||
))
|
||||
|
||||
})
|
||||
.waitFor(CasperUtils.waits.allCommandsFinished, function then() {
|
||||
doneSelectors.forEach(function(selector) {
|
||||
this.test.assertExists(selector);
|
||||
}.bind(this));
|
||||
})
|
||||
.then(function() {
|
||||
this.test.done();
|
||||
});
|
||||
.waitFor(CasperUtils.waits.allCommandsFinished)
|
||||
|
||||
});
|
||||
.then(
|
||||
CasperUtils.asserts.visibleSelectors(doneSelectors)
|
||||
)
|
||||
|
||||
casper.run();
|
||||
.then(CasperUtils.testDone);
|
||||
|
||||
}).run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue