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
860b73c1
...
860b73c128f6c7348e3996d2a34f841496ef7bcd
authored
2012-07-19 11:11:00 +0200
by
oncletom
Committed by
Nicolas Perriault
2012-10-18 09:43:58 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Tests for the new API
1 parent
a97c3562
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
tests/suites/casper/headers.js
tests/suites/casper/headers.js
View file @
860b73c
casper
.
test
.
comment
(
'Casper.
getCurrentHeader
()'
);
casper
.
test
.
comment
(
'Casper.
headers.get
()'
);
var
server
=
require
(
'webserver'
).
create
();
var
service
=
server
.
listen
(
8090
,
function
(
request
,
response
)
{
...
...
@@ -15,21 +15,21 @@ var service = server.listen(8090, function (request, response) {
function
dumpHeaders
()
{
casper
.
test
.
comment
(
'Dumping current response headers'
);
casper
.
getCurrentHeaders
()
.
forEach
(
function
(
header
)
{
casper
.
currentResponse
.
headers
.
forEach
(
function
(
header
)
{
casper
.
test
.
comment
(
'- '
+
header
.
name
+
': '
+
header
.
value
);
});
}
casper
.
start
(
'tests/site/index.html'
,
function
thenLocalPage
()
{
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'Status'
),
null
,
'No Status header on local page'
);
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'Content-Language'
),
null
,
'No Content-Language on local page'
);
this
.
test
.
assert
(
casper
.
getCurrentHeaders
().
length
===
0
,
'No headers sent back'
);
this
.
test
.
assertEquals
(
casper
.
currentResponse
,
undefined
,
'No response available on local page'
);
});
casper
.
thenOpen
(
'http://localhost:8090/'
,
function
thenLocalhost
()
{
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'Content-Language'
),
'en'
,
'Checking existing header'
);
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'content-language'
),
null
,
'Checking header typecase'
);
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'X-Is-Troll'
),
null
,
'Checking unexisting header'
);
var
headers
=
casper
.
currentResponse
.
headers
;
this
.
test
.
assertEquals
(
headers
.
get
(
'Content-Language'
),
'en'
,
'Checking existing header'
);
this
.
test
.
assertEquals
(
headers
.
get
(
'content-language'
),
null
,
'Checking header typecase'
);
this
.
test
.
assertEquals
(
headers
.
get
(
'X-Is-Troll'
),
null
,
'Checking unexisting header'
);
});
casper
.
run
(
function
()
{
...
...
Please
register
or
sign in
to post a comment