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
15411690
...
15411690edb0cf182eb847fb44109c77fdfd56d4
authored
2013-08-27 01:50:59 +0200
by
mickaelandrieu
Committed by
Mickaël Andrieu
2013-09-09 00:58:42 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Correct method, tests and documentation
1 parent
36474308
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
15 deletions
docs/modules/tester.rst
modules/tester.js
tests/suites/tester/assert.js
docs/modules/tester.rst
View file @
1541169
...
...
@@ -450,14 +450,19 @@ Asserts that the provided input is of the given type::
``assertInstanceOf()``
-------------------------------------------------------------------------------
**Signature:** ``assertInstanceOf(mixed input,
String className
[, String message])``
**Signature:** ``assertInstanceOf(mixed input,
function constructor
[, String message])``
Asserts that the provided input is of the given className::
function Cow() {
this.moo = function moo() {
return 'moo!';
};
}
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");
var daisy = new Cow();
test.assertInstanceOf(daisy,
Cow
, "Okay, daisy is a cow.");
test.assertInstanceOf(daisy,
Casper
, "Moo is not Boo");
test.done();
});
...
...
modules/tester.js
View file @
1541169
...
...
@@ -842,20 +842,20 @@ 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
* @param mixed subject
The value to test
* @param
function constructor The object constructor
* @param String message
Test description
* @return Object
An assertion result object
*/
Tester
.
prototype
.
assertInstanceOf
=
function
assertInstanceOf
(
subject
,
c
lassName
,
message
)
{
Tester
.
prototype
.
assertInstanceOf
=
function
assertInstanceOf
(
subject
,
c
onstructor
,
message
)
{
"use strict"
;
var
actual
=
subject
instanceof
c
lassName
;
var
actual
=
subject
instanceof
c
onstructor
;
return
this
.
assert
(
utils
.
equals
(
actual
,
true
),
message
,
{
type
:
"assertInstanceOf"
,
standard
:
f
(
'Subject is an instance of: "%s"'
,
c
lassName
),
standard
:
f
(
'Subject is an instance of: "%s"'
,
c
onstructor
),
values
:
{
subject
:
subject
,
c
lassName
:
className
,
c
onstructor
:
constructor
,
actual
:
actual
}
});
...
...
tests/suites/tester/assert.js
View file @
1541169
...
...
@@ -2,7 +2,7 @@
/*jshint strict:false, maxstatements:99*/
var
fs
=
require
(
'fs'
);
casper
.
test
.
begin
(
'Common assertions tests'
,
4
5
,
function
(
test
)
{
casper
.
test
.
begin
(
'Common assertions tests'
,
4
6
,
function
(
test
)
{
casper
.
start
(
'tests/site/index.html'
,
function
()
{
test
.
assertTextExists
(
'form'
,
'Tester.assertTextExists() checks that page body contains text'
);
test
.
assertTextExist
(
'form'
,
'Tester.assertTextExist() checks that page body contains text [alias]'
);
...
...
@@ -60,7 +60,9 @@ 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"
);
// we need a constructor and an object
function
Cow
(){};
var
daisy
=
new
Cow
();
test
.
assertInstanceOf
(
daisy
,
Cow
,
"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