Commit 1a50e23d 1a50e23d3d92179060f6f90a94af12a98c1f34ac by Nicolas Perriault

added more waitFor* tests

1 parent 3a4ed2c8
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
14 <div id="textChange" > 14 <div id="textChange" >
15 Loading... 15 Loading...
16 </div> 16 </div>
17 <div id="encoded">Voil&agrave;</div>
17 <script> 18 <script>
18 setTimeout(function() { 19 setTimeout(function() {
19 var li = document.createElement('li') 20 var li = document.createElement('li')
......
1 /*global casper*/ 1 /*global casper*/
2 /*jshint strict:false*/ 2 /*jshint strict:false*/
3 casper.test.begin('fetchText() tests', 1, function(test) { 3 casper.test.begin('fetchText() basic tests', 1, function(test) {
4 casper.start('tests/site/index.html', function() { 4 casper.start('tests/site/index.html', function() {
5 test.assertEquals(this.fetchText('ul li'), 'onetwothree', 5 test.assertEquals(this.fetchText('ul li'), 'onetwothree',
6 'Casper.fetchText() can retrieve text contents'); 6 'Casper.fetchText() can retrieve text contents');
...@@ -8,3 +8,14 @@ casper.test.begin('fetchText() tests', 1, function(test) { ...@@ -8,3 +8,14 @@ casper.test.begin('fetchText() tests', 1, function(test) {
8 test.done(); 8 test.done();
9 }); 9 });
10 }); 10 });
11
12 casper.test.begin('fetchText() handles HTML entities', 1, function(test) {
13 casper.start().then(function() {
14 this.setContent('<html><body>Voil&agrave;</body></html>');
15 test.assertEquals(this.fetchText('body'), 'Voilà',
16 'Casper.fetchText() fetches decoded text');
17 });
18 casper.run(function() {
19 test.done();
20 });
21 });
......
...@@ -77,7 +77,7 @@ casper.test.begin('waitForSelector() tests', 1, function(test) { ...@@ -77,7 +77,7 @@ casper.test.begin('waitForSelector() tests', 1, function(test) {
77 }); 77 });
78 }); 78 });
79 79
80 casper.test.begin('waitForText() tests', 2, function(test) { 80 casper.test.begin('waitForText() tests', 4, function(test) {
81 casper.start('tests/site/waitFor.html'); 81 casper.start('tests/site/waitFor.html');
82 82
83 casper.waitForText('<li>four</li>', function() { 83 casper.waitForText('<li>four</li>', function() {
...@@ -92,6 +92,12 @@ casper.test.begin('waitForText() tests', 2, function(test) { ...@@ -92,6 +92,12 @@ casper.test.begin('waitForText() tests', 2, function(test) {
92 test.fail('Casper.waitForText() can wait for regexp'); 92 test.fail('Casper.waitForText() can wait for regexp');
93 }); 93 });
94 94
95 casper.reload().waitForText('Voilà', function() {
96 test.pass('Casper.waitForText() can wait for decoded HTML text');
97 }, function() {
98 test.fail('Casper.waitForText() can wait for decoded HTML text');
99 }, 1000);
100
95 casper.run(function() { 101 casper.run(function() {
96 test.done(); 102 test.done();
97 }); 103 });
......