Commit 4e00038e 4e00038e2b1ef44246f7664ee4b63d18f8176d9b by Shiryaev Andrey

add test

1 parent d2cb5c0f
......@@ -10,6 +10,8 @@
<a id="test3" href="page1.html" onclick="results.test3 = true; return false">test3</a>
<a id="test4" href="http://www.google.com/">test4</a>
<a id="test5" href="#">test5</a>
<a id="test6" href="#">Label with double "quotes"</a>
<a id="test7" href="#">Label with single 'quotes'</a>
<script>
(function(window) {
window.results = {
......@@ -18,6 +20,8 @@
test3: false,
test4: false,
test5: [],
test6: false,
test7: false,
testdown: [],
testup: [],
testmove: [],
......@@ -47,6 +51,14 @@
test5elem.addEventListener('mouseup', function(event) {
results.test5.push('mouseup');
});
document.querySelector('#test6').onclick = function(event) {
results.test6 = true;
event.preventDefault();
};
document.querySelector('#test7').onclick = function(event) {
results.test7 = true;
event.preventDefault();
};
})(window);
</script>
</body>
......
......@@ -40,6 +40,10 @@ casper.test.begin('clickLabel tests tests', 8, function(test) {
'Casper.clickLabel() can click an `onclick=".*; return false"` link');
test.assert(this.clickLabel('test4'),
'Casper.clickLabel() can click an unobstrusive js handled link');
test.assert(this.clickLabel('Label with double "quotes"'),
'Casper.clickLabel() can click the link with double quotes in the label');
test.assert(this.clickLabel("Label with single 'quotes'"),
'Casper.clickLabel() can click the link with the single quotes in the label');
var results = this.getGlobal('results');
test.assert(results.test1,
'Casper.clickLabel() has clicked an `href="javascript:` link');
......@@ -49,6 +53,10 @@ casper.test.begin('clickLabel tests tests', 8, function(test) {
'Casper.clickLabel() has clicked an `onclick=".*; return false"` link');
test.assert(results.test4,
'Casper.clickLabel() has clicked an unobstrusive js handled link');
test.assert(results.test6,
'Casper.clickLabel() has clicked the link with double quotes in the label');
test.assert(results.test7,
'Casper.clickLabel() has clicked the link with single quotes in the label');
}).run(function() {
test.done();
});
......
......@@ -339,6 +339,19 @@ casper.test.begin('objectValues() tests', 2, function(test) {
test.done();
});
casper.test.begin('quoteXPathAttributeString() tests', 2, function(test) {
casper.start('tests/site/click.html', function() {
var selector = utils.format('//a[text()=%s]',
utils.quoteXPathAttributeString('Label with double "quotes"'));
test.assertExists(x(selector), utils.format('Xpath selector "%s" is found on "tests/site/click.html" page', selector));
selector = utils.format('//a[text()=%s]',
utils.quoteXPathAttributeString("Label with single 'quotes'"));
test.assertExists(x(selector), utils.format('Xpath selector "%s" is found on "tests/site/click.html" page', selector));
}).run(function() {
test.done();
});
});
casper.test.begin('unique() tests', 4, function(test) {
var testCases = [
{
......