This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrated casper/confirm tests to new test format
- Loading branch information
Showing
1 changed file
with
21 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
/*global casper*/ | ||
/*jshint strict:false*/ | ||
var received; | ||
|
||
casper.setFilter('page.confirm', function(message) { | ||
received = message; | ||
return true; | ||
}); | ||
|
||
casper.start('tests/site/confirm.html', function() { | ||
this.test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted'); | ||
casper.test.begin('can confirm dialog', 2, function(test) { | ||
var received; | ||
casper.removeAllFilters('page.confirm') | ||
casper.setFilter('page.confirm', function(message) { | ||
received = message; | ||
return true; | ||
}); | ||
casper.start('tests/site/confirm.html', function() { | ||
test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted'); | ||
}); | ||
casper.run(function() { | ||
test.assertEquals(received, 'are you sure?', 'confirmation message is ok'); | ||
test.done(); | ||
}); | ||
}); | ||
|
||
casper.then(function() { | ||
//remove the page.confirm event filter so we can add a new one | ||
casper.test.begin('can cancel dialog', 1, function(test) { | ||
casper.removeAllFilters('page.confirm') | ||
casper.setFilter('page.confirm', function(message) { | ||
return false; | ||
}); | ||
}); | ||
|
||
casper.thenOpen('/tests/site/confirm.html', function() { | ||
this.test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled'); | ||
}); | ||
|
||
casper.run(function() { | ||
this.test.assertEquals(received, 'are you sure?', 'confirmation message is ok'); | ||
this.test.done(3); | ||
casper.start('tests/site/confirm.html', function() { | ||
test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled'); | ||
}); | ||
casper.run(function() { | ||
test.done(); | ||
}); | ||
}); |