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
2118ecbb
...
2118ecbb2c1a29c0f23f2698781d8669dce52781
authored
2013-05-08 22:47:18 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed tests for phantomjs <1.9.0
1 parent
896e8ec8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
40 deletions
tests/suites/casper/keys.js
tests/suites/utils.js
tests/suites/casper/keys.js
View file @
2118ecb
...
...
@@ -18,24 +18,26 @@ casper.test.begin('sendKeys() tests', 3, function(test) {
});
});
casper
.
test
.
begin
(
'sendKeys() key modifiers tests'
,
1
,
function
(
test
)
{
casper
.
start
().
then
(
function
()
{
this
.
setContent
([
'<input>'
,
'<script>var keys = []; window.addEventListener("keypress", function(e) {'
,
' keys.push({code: e.which, alt: e.altKey, ctrl: e.ctrlKey});'
,
'})</script>'
].
join
(
''
));
this
.
sendKeys
(
'input'
,
'k'
);
this
.
sendKeys
(
'input'
,
'k'
,
{
modifiers
:
"ctrl"
});
this
.
sendKeys
(
'input'
,
'k'
,
{
modifiers
:
"ctrl+alt"
});
test
.
assertEquals
(
this
.
getGlobal
(
'keys'
),
[
{
code
:
107
,
alt
:
false
,
ctrl
:
false
},
{
code
:
107
,
alt
:
false
,
ctrl
:
true
},
{
code
:
107
,
alt
:
true
,
ctrl
:
true
}
],
'sendKeys() uses key modifiers'
);
}).
run
(
function
()
{
test
.
done
();
if
(
utils
.
gteVersion
(
phantom
.
version
,
'1.9.0'
))
{
casper
.
test
.
begin
(
'sendKeys() key modifiers tests'
,
1
,
function
(
test
)
{
casper
.
start
().
then
(
function
()
{
this
.
setContent
([
'<input>'
,
'<script>var keys = []; window.addEventListener("keypress", function(e) {'
,
' keys.push({code: e.which, alt: e.altKey, ctrl: e.ctrlKey});'
,
'})</script>'
].
join
(
''
));
this
.
sendKeys
(
'input'
,
'k'
);
this
.
sendKeys
(
'input'
,
'k'
,
{
modifiers
:
"ctrl"
});
this
.
sendKeys
(
'input'
,
'k'
,
{
modifiers
:
"ctrl+alt"
});
test
.
assertEquals
(
this
.
getGlobal
(
'keys'
),
[
{
code
:
107
,
alt
:
false
,
ctrl
:
false
},
{
code
:
107
,
alt
:
false
,
ctrl
:
true
},
{
code
:
107
,
alt
:
true
,
ctrl
:
true
}
],
'sendKeys() uses key modifiers'
);
}).
run
(
function
()
{
test
.
done
();
});
});
}
);
}
...
...
tests/suites/utils.js
View file @
2118ecb
...
...
@@ -52,26 +52,28 @@ casper.test.begin('utils.clone() tests', 2, function(test) {
test
.
done
();
});
casper
.
test
.
begin
(
'utils.computeModifier() tests'
,
7
,
function
(
test
)
{
var
modifiers
=
require
(
'webpage'
).
create
().
event
.
modifier
;
test
.
assertType
(
modifiers
,
"object"
);
test
.
assertEquals
(
utils
.
computeModifier
(
""
,
modifiers
),
0
,
'computeModifier() computes a "none" modifier'
);
test
.
assertEquals
(
utils
.
computeModifier
(
"alt"
,
modifiers
),
modifiers
.
alt
,
'computeModifier() computes an "alt" modifier'
);
test
.
assertEquals
(
utils
.
computeModifier
(
"ctrl+alt"
,
modifiers
),
modifiers
.
ctrl
|
modifiers
.
alt
,
'computeModifier() computes a "ctrl+alt" modifier'
);
test
.
assertEquals
(
utils
.
computeModifier
(
"ctrl+alt+shift"
,
modifiers
),
modifiers
.
ctrl
|
modifiers
.
alt
|
modifiers
.
shift
,
'computeModifier() computes a "ctrl+alt+shift" modifier'
);
test
.
assertThrows
(
utils
.
computeModifier
,
[
"chucknorris"
,
modifiers
],
'computeModifier() checks for a valid modifier'
);
test
.
assertThrows
(
utils
.
computeModifier
,
[
"chuck+norris"
,
modifiers
],
'computeModifier() checks for a valid complex modifier'
);
test
.
done
();
});
if
(
utils
.
gteVersion
(
phantom
.
version
,
'1.9.0'
))
{
casper
.
test
.
begin
(
'utils.computeModifier() tests'
,
7
,
function
(
test
)
{
var
modifiers
=
require
(
'webpage'
).
create
().
event
.
modifier
;
test
.
assertType
(
modifiers
,
"object"
);
test
.
assertEquals
(
utils
.
computeModifier
(
""
,
modifiers
),
0
,
'computeModifier() computes a "none" modifier'
);
test
.
assertEquals
(
utils
.
computeModifier
(
"alt"
,
modifiers
),
modifiers
.
alt
,
'computeModifier() computes an "alt" modifier'
);
test
.
assertEquals
(
utils
.
computeModifier
(
"ctrl+alt"
,
modifiers
),
modifiers
.
ctrl
|
modifiers
.
alt
,
'computeModifier() computes a "ctrl+alt" modifier'
);
test
.
assertEquals
(
utils
.
computeModifier
(
"ctrl+alt+shift"
,
modifiers
),
modifiers
.
ctrl
|
modifiers
.
alt
|
modifiers
.
shift
,
'computeModifier() computes a "ctrl+alt+shift" modifier'
);
test
.
assertThrows
(
utils
.
computeModifier
,
[
"chucknorris"
,
modifiers
],
'computeModifier() checks for a valid modifier'
);
test
.
assertThrows
(
utils
.
computeModifier
,
[
"chuck+norris"
,
modifiers
],
'computeModifier() checks for a valid complex modifier'
);
test
.
done
();
});
}
casper
.
test
.
begin
(
'equals() tests'
,
23
,
function
(
test
)
{
test
.
assert
(
utils
.
equals
(
null
,
null
),
'equals() null equality'
);
...
...
Please
register
or
sign in
to post a comment