add test
Showing
3 changed files
with
33 additions
and
0 deletions
... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
10 | <a id="test3" href="page1.html" onclick="results.test3 = true; return false">test3</a> | 10 | <a id="test3" href="page1.html" onclick="results.test3 = true; return false">test3</a> |
11 | <a id="test4" href="http://www.google.com/">test4</a> | 11 | <a id="test4" href="http://www.google.com/">test4</a> |
12 | <a id="test5" href="#">test5</a> | 12 | <a id="test5" href="#">test5</a> |
13 | <a id="test6" href="#">Label with double "quotes"</a> | ||
14 | <a id="test7" href="#">Label with single 'quotes'</a> | ||
13 | <script> | 15 | <script> |
14 | (function(window) { | 16 | (function(window) { |
15 | window.results = { | 17 | window.results = { |
... | @@ -18,6 +20,8 @@ | ... | @@ -18,6 +20,8 @@ |
18 | test3: false, | 20 | test3: false, |
19 | test4: false, | 21 | test4: false, |
20 | test5: [], | 22 | test5: [], |
23 | test6: false, | ||
24 | test7: false, | ||
21 | testdown: [], | 25 | testdown: [], |
22 | testup: [], | 26 | testup: [], |
23 | testmove: [], | 27 | testmove: [], |
... | @@ -47,6 +51,14 @@ | ... | @@ -47,6 +51,14 @@ |
47 | test5elem.addEventListener('mouseup', function(event) { | 51 | test5elem.addEventListener('mouseup', function(event) { |
48 | results.test5.push('mouseup'); | 52 | results.test5.push('mouseup'); |
49 | }); | 53 | }); |
54 | document.querySelector('#test6').onclick = function(event) { | ||
55 | results.test6 = true; | ||
56 | event.preventDefault(); | ||
57 | }; | ||
58 | document.querySelector('#test7').onclick = function(event) { | ||
59 | results.test7 = true; | ||
60 | event.preventDefault(); | ||
61 | }; | ||
50 | })(window); | 62 | })(window); |
51 | </script> | 63 | </script> |
52 | </body> | 64 | </body> | ... | ... |
... | @@ -40,6 +40,10 @@ casper.test.begin('clickLabel tests tests', 8, function(test) { | ... | @@ -40,6 +40,10 @@ casper.test.begin('clickLabel tests tests', 8, function(test) { |
40 | 'Casper.clickLabel() can click an `onclick=".*; return false"` link'); | 40 | 'Casper.clickLabel() can click an `onclick=".*; return false"` link'); |
41 | test.assert(this.clickLabel('test4'), | 41 | test.assert(this.clickLabel('test4'), |
42 | 'Casper.clickLabel() can click an unobstrusive js handled link'); | 42 | 'Casper.clickLabel() can click an unobstrusive js handled link'); |
43 | test.assert(this.clickLabel('Label with double "quotes"'), | ||
44 | 'Casper.clickLabel() can click the link with double quotes in the label'); | ||
45 | test.assert(this.clickLabel("Label with single 'quotes'"), | ||
46 | 'Casper.clickLabel() can click the link with the single quotes in the label'); | ||
43 | var results = this.getGlobal('results'); | 47 | var results = this.getGlobal('results'); |
44 | test.assert(results.test1, | 48 | test.assert(results.test1, |
45 | 'Casper.clickLabel() has clicked an `href="javascript:` link'); | 49 | 'Casper.clickLabel() has clicked an `href="javascript:` link'); |
... | @@ -49,6 +53,10 @@ casper.test.begin('clickLabel tests tests', 8, function(test) { | ... | @@ -49,6 +53,10 @@ casper.test.begin('clickLabel tests tests', 8, function(test) { |
49 | 'Casper.clickLabel() has clicked an `onclick=".*; return false"` link'); | 53 | 'Casper.clickLabel() has clicked an `onclick=".*; return false"` link'); |
50 | test.assert(results.test4, | 54 | test.assert(results.test4, |
51 | 'Casper.clickLabel() has clicked an unobstrusive js handled link'); | 55 | 'Casper.clickLabel() has clicked an unobstrusive js handled link'); |
56 | test.assert(results.test6, | ||
57 | 'Casper.clickLabel() has clicked the link with double quotes in the label'); | ||
58 | test.assert(results.test7, | ||
59 | 'Casper.clickLabel() has clicked the link with single quotes in the label'); | ||
52 | }).run(function() { | 60 | }).run(function() { |
53 | test.done(); | 61 | test.done(); |
54 | }); | 62 | }); | ... | ... |
... | @@ -339,6 +339,19 @@ casper.test.begin('objectValues() tests', 2, function(test) { | ... | @@ -339,6 +339,19 @@ casper.test.begin('objectValues() tests', 2, function(test) { |
339 | test.done(); | 339 | test.done(); |
340 | }); | 340 | }); |
341 | 341 | ||
342 | casper.test.begin('quoteXPathAttributeString() tests', 2, function(test) { | ||
343 | casper.start('tests/site/click.html', function() { | ||
344 | var selector = utils.format('//a[text()=%s]', | ||
345 | utils.quoteXPathAttributeString('Label with double "quotes"')); | ||
346 | test.assertExists(x(selector), utils.format('Xpath selector "%s" is found on "tests/site/click.html" page', selector)); | ||
347 | selector = utils.format('//a[text()=%s]', | ||
348 | utils.quoteXPathAttributeString("Label with single 'quotes'")); | ||
349 | test.assertExists(x(selector), utils.format('Xpath selector "%s" is found on "tests/site/click.html" page', selector)); | ||
350 | }).run(function() { | ||
351 | test.done(); | ||
352 | }); | ||
353 | }); | ||
354 | |||
342 | casper.test.begin('unique() tests', 4, function(test) { | 355 | casper.test.begin('unique() tests', 4, function(test) { |
343 | var testCases = [ | 356 | var testCases = [ |
344 | { | 357 | { | ... | ... |
-
Please register or sign in to post a comment