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
3ac34514
...
3ac34514101568995c11816836ccffffd46e1888
authored
2013-11-14 16:56:17 -0800
by
Matthew DuVall
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add docs and throw exception when type is invalid, test coverage
1 parent
d3b876ec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
docs/modules/tester.rst
modules/tester.js
tests/suites/tester/assert.js
docs/modules/tester.rst
View file @
3ac3451
...
...
@@ -160,9 +160,9 @@ Asserts that a given subject is `falsy <http://11heavens.com/falsy-and-truthy-in
``assertField()``
-------------------------------------------------------------------------------
**Signature:** ``assertField(String|
o
bject input, String expected[, String message, Object options])``
**Signature:** ``assertField(String|
O
bject input, String expected[, String message, Object options])``
Asserts that a given form field has the provided value::
Asserts that a given form field has the provided value
with input name or :ref:`selector expression <selectors>`
::
casper.test.begin('assertField() tests', 1, function(test) {
casper.start('http://www.google.fr/', function() {
...
...
modules/tester.js
View file @
3ac3451
...
...
@@ -450,6 +450,7 @@ Tester.prototype.assertEvalEqual = function assertEvalEquals(fn, expected, messa
};
function
baseFieldAssert
(
inputName
,
expected
,
actual
,
message
)
{
/*jshint validthis:true */
"use strict"
;
return
this
.
assert
(
utils
.
equals
(
actual
,
expected
),
message
,
{
...
...
@@ -503,6 +504,8 @@ Tester.prototype.assertField = function assertField(input, expected, message, op
return
this
.
assertFieldCSS
(
input
.
path
,
expected
,
message
);
case
'xpath'
:
return
this
.
assertFieldXPath
(
input
.
path
,
expected
,
message
);
default
:
throw
new
CasperError
(
'Invalid regexp.'
);
// no default
}
}
...
...
tests/suites/tester/assert.js
View file @
3ac3451
...
...
@@ -170,6 +170,25 @@ casper.test.begin('Tester.assertField(): XPath selectors', 1, function(test) {
});
});
casper
.
test
.
begin
(
'Tester.assertField(): invalid selectors'
,
1
,
function
(
test
)
{
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
'email'
:
'albert@camus.com'
});
test
.
assertRaise
(
function
()
{
test
.
assertField
({
type
:
'albert'
},
'albert@camus.com'
,
'Tester.assertField() works as expected with XPath selectors'
);
},
[],
'should throw an error for an invalid selector'
);
}).
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Tester.assertFieldCSS(): CSS selectors'
,
1
,
function
(
test
)
{
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
...
...
@@ -200,4 +219,4 @@ casper.test.begin('Tester.assertFieldXPath(): XPath selectors', 1, function(test
}).
run
(
function
()
{
test
.
done
();
});
});
\ No newline at end of file
});
...
...
Please
register
or
sign in
to post a comment