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
0644fff6
...
0644fff699eb04c1784c909857ef8ffa2ce2a5cc
authored
2012-07-18 16:49:13 +0200
by
oncletom
Committed by
Nicolas Perriault
2012-10-18 09:43:57 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Expected headers on server request
1 parent
4949dad8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
tests/suites/casper/headers.js
tests/suites/casper/headers.js
View file @
0644fff
casper
.
test
.
comment
(
'Casper.getCurrentHeader()'
);
function
dumpHeaders
()
{
var
server
=
require
(
'webserver'
).
create
();
var
service
=
server
.
listen
(
8090
,
function
(
request
,
response
)
{
response
.
statusCode
=
200
;
response
.
headers
=
{
'Content-Language'
:
'en'
,
'Content-Type'
:
'text/html'
,
'Date'
:
new
Date
().
toUTCString
()
};
response
.
write
(
"\o/"
);
response
.
close
();
});
function
dumpHeaders
()
{
casper
.
test
.
comment
(
'Dumping current response headers'
);
casper
.
getCurrentHeaders
().
forEach
(
function
(
header
)
{
casper
.
test
.
comment
(
'- '
+
header
.
name
+
': '
+
header
.
value
);
casper
.
getCurrentHeaders
().
forEach
(
function
(
header
)
{
casper
.
test
.
comment
(
'- '
+
header
.
name
+
': '
+
header
.
value
);
});
}
casper
.
start
(
'tests/site/index.html'
,
function
then
()
{
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'Status'
),
null
,
'No Status header on local page'
);
this
.
test
.
assert
(
casper
.
getCurrentHeaders
().
length
===
0
,
'No headers sent back'
);
casper
.
start
(
'tests/site/index.html'
,
function
then
LocalPage
()
{
this
.
test
.
assertEquals
(
casper
.
getCurrentHeader
(
'Status'
),
null
,
'No Status header on local page'
);
this
.
test
.
assert
(
casper
.
getCurrentHeaders
().
length
===
0
,
'No headers sent back'
);
});
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'
);
});
casper
.
run
(
function
(){
this
.
test
.
done
();
casper
.
run
(
function
()
{
server
.
close
();
this
.
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment