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
38435be8
...
38435be89aa10f3304d747c1ec34a6d1f75fb886
authored
2014-03-08 20:41:08 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #840 from r8k/master
fixes #832 #196
2 parents
b00b295f
7646ea06
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletions
modules/casper.js
tests/suites/casper/open.js
modules/casper.js
View file @
38435be
...
...
@@ -1397,7 +1397,7 @@ Casper.prototype.open = function open(location, settings) {
// http data
if
(
settings
.
data
)
{
if
(
utils
.
isObject
(
settings
.
data
))
{
// query object
if
(
settings
.
headers
&&
settings
.
headers
[
"Content-Type"
]
===
"application/json"
)
{
if
(
settings
.
headers
&&
settings
.
headers
[
"Content-Type"
]
.
match
(
/application
\/
json/
)
)
{
settings
.
data
=
JSON
.
stringify
(
settings
.
data
);
// convert object to JSON notation
}
else
{
settings
.
data
=
qs
.
encode
(
settings
.
data
);
// escapes all characters except alphabetic, decimal digits and ,-_.!~*'()
...
...
tests/suites/casper/open.js
View file @
38435be
...
...
@@ -130,6 +130,37 @@ casper.test.begin('open() POST json object', 2, {
}
});
casper
.
test
.
begin
(
'open() POST json object with charset info'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
open
(
'tests/site/index.html'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json; charset=utf-8'
},
data
:
{
plop
:
42
,
chuck
:
'norris'
,
john
:
{
'Doe'
:
'is here'
}
}
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can POST a JSON object"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"POST"
,
headers
:
{
'Content-Type'
:
'application/json; charset=utf-8'
},
data
:
'{"plop":42,"chuck":"norris","john":{"Doe":"is here"}}'
},
"Casper.open() used the expected POST settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() PUT tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
Please
register
or
sign in
to post a comment