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
07344b38
...
07344b389938b2c3b8b2e0803cd9a0ec3b7a4e63
authored
2012-11-02 09:32:27 -0700
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #266 from starlocke/fix_tester_module
Fix Tester module and its selftest
2 parents
8c798c7a
5ef5a718
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
4 deletions
modules/tester.js
tests/suites/tester.js
modules/tester.js
View file @
07344b3
...
...
@@ -267,7 +267,7 @@ Tester.prototype.assertField = function assertField(inputName, expected, messag
* @param String message Test description
* @return Object An assertion result object
*/
Tester
.
prototype
.
assertExists
=
Tester
.
prototype
.
assertExist
=
this
.
assertSelectorExists
=
Tester
.
prototype
.
assertSelectorExist
=
function
assertExists
(
selector
,
message
)
{
Tester
.
prototype
.
assertExists
=
Tester
.
prototype
.
assertExist
=
Tester
.
prototype
.
assertSelectorExists
=
Tester
.
prototype
.
assertSelectorExist
=
function
assertExists
(
selector
,
message
)
{
"use strict"
;
return
this
.
assert
(
this
.
casper
.
exists
(
selector
),
message
,
{
type
:
"assertExists"
,
...
...
@@ -382,7 +382,7 @@ Tester.prototype.assertNotVisible = Tester.prototype.assertInvisible = function
* @param String message Test description
* @return Object An assertion result object
*/
Tester
.
prototype
.
assertRaises
=
Tester
.
prototype
.
assertRaise
=
this
.
assertThrows
=
function
assertRaises
(
fn
,
args
,
message
)
{
Tester
.
prototype
.
assertRaises
=
Tester
.
prototype
.
assertRaise
=
Tester
.
prototype
.
assertThrows
=
function
assertRaises
(
fn
,
args
,
message
)
{
"use strict"
;
var
context
=
{
type
:
"assertRaises"
,
...
...
tests/suites/tester.js
View file @
07344b3
...
...
@@ -25,23 +25,30 @@ casper.thenOpen('tests/site/index.html', function() {
t
.
comment
(
'Tester.assertTextExists()'
);
t
.
assertTextExists
(
'form'
,
'Tester.assertTextExists() checks that page body contains text'
);
t
.
comment
(
'Tester.assertTextExist()'
);
t
.
assertTextExist
(
'form'
,
'Tester.assertTextExist() checks that page body contains text [alias]'
);
t
.
comment
(
'Tester.assertSelectorHasText()'
);
t
.
assertSelectorHasText
(
'h1'
,
'Title'
,
'Tester.assertSelectorHasText() works as expected'
);
t
.
comment
(
'Tester.assertSelectorDoesntHaveText()'
);
t
.
assertSelectorDoesntHaveText
(
'h1'
,
'Subtitle'
,
'Tester.assertSelectorDoesntHaveText() works as expected'
);
});
casper
.
then
(
function
()
{
t
.
comment
(
'Tester.assert()'
);
t
.
assert
(
true
,
'Tester.assert() works as expected'
);
t
.
comment
(
'Tester.assertTrue()'
);
t
.
assertTrue
(
true
,
'Tester.assertTrue() works as expected [alias]'
);
t
.
comment
(
'Tester.assertNot()'
);
t
.
assertNot
(
false
,
'Tester.assertNot() works as expected'
);
t
.
comment
(
'Tester.assertEquals()'
);
t
.
assertEquals
(
true
,
true
,
'Tester.assertEquals() works as expected'
);
t
.
comment
(
'Tester.assertEqual()'
);
t
.
assertEqual
(
true
,
true
,
'Tester.assertEqual() works as expected [alias]'
);
t
.
comment
(
'Tester.assertNotEquals()'
);
t
.
assertNotEquals
(
true
,
false
,
'Tester.assertNotEquals() works as expected'
);
...
...
@@ -50,17 +57,39 @@ casper.then(function() {
return
true
;
},
'Tester.assertEval() works as expected'
);
t
.
comment
(
'Tester.assertEvaluate()'
);
t
.
assertEvaluate
(
function
()
{
return
true
;
},
'Tester.assertEvaluate() works as expected [alias]'
);
t
.
comment
(
'Tester.assertEvalEquals()'
);
t
.
assertEvalEquals
(
function
()
{
return
42
;
},
42
,
'Tester.assertEvalEquals() works as expected'
);
t
.
comment
(
'Tester.assertEvalEqual()'
);
t
.
assertEvalEqual
(
function
()
{
return
42
;
},
42
,
'Tester.assertEvalEqual() works as expected [alias]'
);
t
.
comment
(
'Tester.assertExists()'
);
t
.
assertExists
(
'body'
,
'Tester.assertExists() works as expected'
);
t
.
comment
(
'Tester.assertExist()'
);
t
.
assertExist
(
'body'
,
'Tester.assertExist() works as expected [alias]'
);
t
.
comment
(
'Tester.assertSelectorExists()'
);
t
.
assertSelectorExists
(
'body'
,
'Tester.assertSelectorExists() works as expected [alias]'
);
t
.
comment
(
'Tester.assertSelectorExists()'
);
t
.
assertSelectorExist
(
'body'
,
'Tester.assertSelectorExist() works as expected [alias]'
);
t
.
comment
(
'Tester.assertDoesntExist()'
);
t
.
assertDoesntExist
(
'foobar'
,
'Tester.assertDoesntExist() works as expected'
);
t
.
comment
(
'Tester.assertNotExist()'
);
t
.
assertDoesntExist
(
'foobar'
,
'Tester.assertNotExist() works as expected [alias]'
);
t
.
comment
(
'Tester.assertHttpStatus()'
);
// using file:// protocol, HTTP status is always null
t
.
assertHttpStatus
(
200
,
'Tester.assertHttpStatus() works as expected'
);
...
...
@@ -68,31 +97,56 @@ casper.then(function() {
t
.
comment
(
'Tester.assertMatch()'
);
t
.
assertMatch
(
"the lazy dog"
,
/lazy/
,
'Tester.assertMatch() works as expected'
);
t
.
comment
(
'Tester.assertMatches()'
);
t
.
assertMatches
(
"the lazy dog"
,
/lazy/
,
'Tester.assertMatches() works as expected [alias]'
);
t
.
comment
(
'Tester.assertRaises()'
);
t
.
assertRaises
(
function
()
{
throw
new
Error
(
'plop'
);
},
[],
'Tester.assertRaises() works as expected'
);
t
.
comment
(
'Tester.assertRaise()'
);
t
.
assertRaise
(
function
()
{
throw
new
Error
(
'plop'
);
},
[],
'Tester.assertRaise() works as expected [alias]'
);
t
.
comment
(
'Tester.assertThrows()'
);
t
.
assertThrows
(
function
()
{
throw
new
Error
(
'plop'
);
},
[],
'Tester.assertThrows() works as expected [alias]'
);
t
.
comment
(
'Tester.assertResourceExists()'
);
t
.
assertResourceExists
(
/index
\.
html/
,
'Tester.assertResourceExists() works as expected'
);
t
.
comment
(
'Tester.assertResourceExist()'
);
t
.
assertResourceExist
(
/index
\.
html/
,
'Tester.assertResourceExist() works as expected [alias]'
);
t
.
comment
(
'Tester.assertTitle()'
);
t
.
assertTitle
(
'CasperJS test index'
,
'Tester.assertTitle() works as expected'
);
t
.
comment
(
'Tester.assertTitleMatch()'
);
t
.
assertTitleMatch
(
/test index/
,
'Tester.assertTitleMatch() works as expected'
);
t
.
comment
(
'Tester.assertTitleMatches()'
);
t
.
assertTitleMatches
(
/test index/
,
'Tester.assertTitleMatches() works as expected [alias]'
);
t
.
comment
(
'Tester.assertType()'
);
t
.
assertType
(
"plop"
,
"string"
,
"Tester.assertType() works as expected"
);
t
.
comment
(
'Tester.assertUrlMatch()'
);
t
.
assertUrlMatch
(
/index
\.
html$/
,
"Tester.assertUrlMatch() works as expected"
);
t
.
comment
(
'Tester.assertUrlMatches()'
);
t
.
assertUrlMatches
(
/index
\.
html$/
,
"Tester.assertUrlMatches() works as expected [alias]"
);
t
.
comment
(
'Tester.assertVisible()'
);
t
.
assertVisible
(
'img'
,
'Tester.assertVisible() works as expected'
);
t
.
comment
(
'Tester.assertNotVisible()'
);
t
.
assertNotVisible
(
'p#hidden'
,
'Tester.assertNotVisible() works as expected'
);
t
.
comment
(
'Tester.assertInvisible()'
);
t
.
assertInvisible
(
'p#hidden'
,
'Tester.assertInvisible() works as expected [alias]'
);
});
casper
.
thenOpen
(
'tests/site/form.html'
,
function
()
{
...
...
Please
register
or
sign in
to post a comment