Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
4e00038e
...
4e00038e2b1ef44246f7664ee4b63d18f8176d9b
authored
2013-07-09 01:24:39 +0400
by
Shiryaev Andrey
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add test
1 parent
d2cb5c0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
tests/site/click.html
tests/suites/casper/click.js
tests/suites/utils.js
tests/site/click.html
View file @
4e00038
...
...
@@ -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>
...
...
tests/suites/casper/click.js
View file @
4e00038
...
...
@@ -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
();
});
...
...
tests/suites/utils.js
View file @
4e00038
...
...
@@ -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
=
[
{
...
...
Please
register
or
sign in
to post a comment