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
c7d5a1cf
...
c7d5a1cf2fe536f6dd1e07d3af05d0d9164e48e2
authored
2013-08-26 20:48:22 +0200
by
mickaelandrieu
Committed by
Mickaël Andrieu
2013-09-09 00:58:40 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
introduce new assertInstanceOf() method
1 parent
55b7b251
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
docs/modules/tester.rst
modules/tester.js
tests/suites/tester/assert.js
docs/modules/tester.rst
View file @
c7d5a1c
...
...
@@ -445,6 +445,22 @@ Asserts that the provided input is of the given type::
.. note:: Type names are always expressed in lower case.
.. index:: InstanceOf
``assertInstanceOf()``
-------------------------------------------------------------------------------
**Signature:** ``assertInstanceOf(mixed input, String className[, String message])``
Asserts that the provided input is of the given className::
casper.test.begin('assertInstanceOf() tests', 1, function suite(test) {
var daisy = new Cow(){};
test.assertInstanceOf(daisy, "Cow", "Okay, daisy is a cow.");
test.assertInstanceOf(daisy, "Casper", "Moo is not Boo");
test.done();
});
.. index:: URL
``assertUrlMatch()``
...
...
modules/tester.js
View file @
c7d5a1c
...
...
@@ -840,6 +840,28 @@ Tester.prototype.assertType = function assertType(subject, type, message) {
};
/**
* Asserts that the provided subject is of the given class name.
*
* @param mixed subject The value to test
* @param String className The javascript class name
* @param String message Test description
* @return Object An assertion result object
*/
Tester
.
prototype
.
assertInstanceOf
=
function
assertInstanceOf
(
subject
,
className
,
message
)
{
"use strict"
;
var
actual
=
subject
instanceof
className
;
return
this
.
assert
(
utils
.
equals
(
actual
,
true
),
message
,
{
type
:
"assertType"
,
standard
:
f
(
'Subject is an instance of: "%s"'
,
className
),
values
:
{
subject
:
subject
,
className
:
className
,
actual
:
actual
}
});
};
/**
* Asserts that a the current page url matches a given pattern. A pattern may be
* either a RegExp object or a String. The method will test if the URL matches
* the pattern or contains the String.
...
...
tests/suites/tester/assert.js
View file @
c7d5a1c
...
...
@@ -60,6 +60,7 @@ casper.test.begin('Common assertions tests', 45, function(test) {
test
.
assertTitleMatch
(
/test index/
,
'Tester.assertTitleMatch() works as expected'
);
test
.
assertTitleMatches
(
/test index/
,
'Tester.assertTitleMatches() works as expected [alias]'
);
test
.
assertType
(
"plop"
,
"string"
,
"Tester.assertType() works as expected"
);
test
.
assertInstanceOf
(
casper
,
"Casper"
,
"Tester.assertInstanceOf() works as expected"
);
test
.
assertUrlMatch
(
/index
\.
html$/
,
"Tester.assertUrlMatch() works as expected"
);
test
.
assertUrlMatches
(
/index
\.
html$/
,
"Tester.assertUrlMatches() works as expected [alias]"
);
test
.
assertVisible
(
'img'
,
'Tester.assertVisible() works as expected'
);
...
...
Please
register
or
sign in
to post a comment